Exercise 3 - Perform a Patch Scan
Goal
Perform a patch scan of the machine group you created in Exercise 2.
Requirements
You will need to know the ID of the machine group and the ID of the patch scan template you want to use when performing the scan.
- Establish a session credential (see Session Credentials)
- To determine the machine group ID, look in the output from Exercise 2
- To determine the IDs of the available patch scan templates, perform the following GET request:
In the sample output in Exercise 2, the machine group ID is 1006.
https://localhost:3121/st/console/api/v1.0/patch/scantemplates
Try it yourself
Perform a patch scan of the machine group named Sample Group by submitting a POST request similar to the following:
Change the machineGroupIds, templateId and runAsCredentialId values as needed.
Postman example
https://localhost:3121/st/console/api/v1.0/patch/scans { "machineGroupIds":["1006"], "name":"Scan of Sample Group", "templateId":"4c7069eb-6e1c-4352-91fc-04d4d8abc07b", }
PowerShell script example
$patchScanTemplateId = "4c7069eb-6e1c-4352-91fc-04d4d8abc07b" $machineGroupId = "1006" $patchScanUrl = "https://localhost:3121/st/console/api/v1.0/patch/scans" $patchScanBody = @{ MachineGroupIds = @( $machineGroupId ); Name = "Scan of Sample Group"; TemplateId = $patchScanTemplateId; } | ConvertTo-Json -Depth 99 $scan = Invoke-WebRequest -Method Post -Credential $credential -Uri $patchScanUrl -Body $patchScanBody -ContentType "application/json" | ConvertTo-Json -Depth 99
Output
The result is a JSON-formatted response similar to the following:
StatusCode:
202
Content:
{ "id": "8bce9fdd-0cf8-40b0-8ecc-b0914a9c831a", "isComplete": false, "links": { "self": { "href": "https://device-name.example.com:3121/st/console/api/v1.0/patch/scans/8bce9fdd-0cf8-40b0-8ecc-b0914a9c831a" } }, "name": "Scan of Sample Group", "scanType": "Patch", "startedOn": "2018-07-17T15:15:10.7892367Z", "updatedOn": "2018-07-17T15:15:10.7892367Z", "user": "SYSTEM" }
Headers:
{ [Operation-Location, https://device-name.example.com:3121/st/console/api/v1.0/operations/744206e5-90de-4298-bdb9-98676e2c1974], [Content-Length, 353], [Content-Type, application/json; charset=utf-8], [Date, Mon, 29 Apr 2019 19:26:21 GMT] }