I am trying to run get job data via the Powershell Universal API. It will need to run on our monitoring server. I am able to use Connect-PSUServer but when trying to get any data with a PSU cmdlet I get the following error:
Get-PSUJob : Method not found: 'System.Buffers.ReadOnlySequence`1<Byte> Grpc.Core.DeserializationContext.PayloadAsReadOnlySequence()'.
At line:1 char:1
+ Get-PSUJob
+ ~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-PSUJob], MissingMethodException
+ FullyQualifiedErrorId : System.MissingMethodException,UniversalAutomation.GetJobCommand
To avoid dealing with the Universal module I am trying to access the API directly via Invoke-RestMethod. I am able to schedules perfectly with this:
$Params = @{
Uri = "$HostName/api/v1/schedule"
Method = "GET"
Headers = @{Authorization = "Bearer $Apptoken"}
ContentType = 'application/json'
}
$AllSchedules = Invoke-RestMethod @Params
However I am unable to get any job data. The URI worked for me in the past but now its returning no data
PS C:\WINDOWS\system32> $Params = @{
>> Uri = "$HostName/api/v1/script/$ScriptName/job"
>> Method = "GET"
>> Headers = @{Authorization = "Bearer $Apptoken"}
>> ContentType = 'application/json'
>> }
PS C:\WINDOWS\system32> Invoke-RestMethod @Params
page : {}
take : 0
skip : 0
total : 11
orderBy :
orderDirection : 0
status :
tag :
identity :
script :
child : True
trigger : True
archived : False
scheduled : True
scheduleId : 0
scheduleName :
parent :
statuses :
environment :
variants :
today : False
parentId : 0
search :
excludedScripts :
PS C:\WINDOWS\system32> (Invoke-RestMethod @Params).page
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32>
I have also tried using the script ID instead of the script name, but got the same results. I also confirmed that I can get script data by removing the /job in the URI. Does anybody know what the URI is to get jobs?