Unable to run PowerShell commands on the Windows server where the MID Server is installed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
I am unable to run PowerShell commands on the Windows server where the MID Server is installed. My use case is to upload a file into servicenow from midserver folder files. I am able to discover the Windows server through the MID Server (Quick discovery) and run a few basic commands. However, when I try to run the following PowerShell command, I receive the error message shown below. There are no firewall issues, and I can access the files and paths from the pattern debug, but I am unable to understand why my code is not working in the probe. Any suggestions would be appreciated
This is the powershell script:
# Eg. User name="admin", Password="admin" for this code sample.
$user = "admin"
$pass = "Welcome@123"
# Build auth header
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user, $pass)))
# Set proper headers
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add('Authorization',('Basic {0}' -f $base64AuthInfo))
$headers.Add('Accept','application/json')
$headers.Add('Content-Type','application/json')
# $headers.Add('Content-Type','text/plain') ??didn't seem to need this
# Specify endpoint uri
$uri = "https://xxxxx.service-now.com/api/now/attachment/file?table_name=incident&table_sys_id=a9e76edf87c8f..."
# Specifiy file to attach
$fileToAttach = "C:/RPA Screenshots/QueueProcess.png"
# Specify HTTP method (POST, PATCH, PUT)
$method = "POST"
# Send HTTP request
$response = Invoke-WebRequest -Headers $headers -Method $method -Uri $uri -InFile $fileToAttach
# Print response
$response.RawContent
This command i had written in the WMI Probe under Probe Parameters value
