[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $ServiceLocation = "http://localhost/api/v1" $authHeader = "Bearer 265fa20a-ba69-47a0-aab5-034fba50e062:fzMQKFhuOb63ydsOFmJJtExe6mttWFSr" $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add('Authorization', $authHeader) $response = $null $response = Invoke-RestMethod "$ServiceLocation/scheduler/userSettings" -headers $headers -Method Get -ContentType "application/json" Write-Host "Querying the user settings endpoint returned $response" function Stop-Rampiva-Job { param( [Parameter(Mandatory=$true)] [string] $JobId ) $submission =@{ "command"="STOP" } $json = $submission | ConvertTo-Json $result = $null $result = Invoke-RestMethod "$ServiceLocation/scheduler/jobs/$JobId/execution" -Method Put -Body $json -ContentType "application/json" -headers $headers return } # Get running Jobs $jobs= $null $jobs= Invoke-RestMethod "$ServiceLocation/scheduler/jobs" -headers $headers -Method Get -ContentType "application/json" Write-Host "Got $($jobs.Length) job(s)" Foreach ($job in $jobs) { if ($job.executionState -eq "RUNNING") { Write-Host "Job [$($job.Name)] is running, stopping" Stop-Rampiva-Job -JobId $job.Id } else { Write-Host "Job [$($job.Name)] is in state $($job.executionState), skipping" } }