Automox Script Overview: Start a Scan from a Device
Have you ever needed to run a scan from the client side?
There are times when you may want to trigger a scan from the device as part of an automation rather than from the console (or waiting for the next scheduled scan to run). For example, you want to automatically update the Automox inventory when a Windows 10 in-place upgrade successfully completes.
This script leverages the API to identify the local device, and then sends a secondary API call to schedule a scan for itself. Access this script in the original posting on the Automox community.
There are two areas in the code you’ll need to update to get the script to function:
- $orgID = ‘YOUR_ORG_ID’ - Put your Org ID, which can be found by looking at the URL of your Automox console and selecting the value after the “?o=”: for example, in the URL, https://console.automox.com/dashboard?o=999999, the Org ID would be 999999.
- $apiKey = ‘YOUR_API_KEY’ - In your Automox console, go to Settings > API and select the API key. Note that the API key is per admin user, so you and another admin in your console will have different API keys.
Once you’ve made those two changes, you can run the script on any Windows device using PowerShell.
If you wish to run the script in a test mode to verify the computer is being properly identified locally and through the API return, you can uncomment this line:
#echo "device: $serverName `t serverID: $ServerID `t hostname: $hostName"
and comment out the line that requests the scan for the device:
$getOSResponse = Invoke-WebRequest -UseBasicParsing -Method Post -Uri $getURI -Headers $headers -Body($body| ConvertTo-Json)
That will show you the device name, device ID, and the hostname as well as generate the json files to $logPath to help with troubleshooting.
Tips for Creating an Automox Worklet
Before deploying an Automox Worklet to the production environment, we suggest testing this on a few devices to confirm its accuracy. If you have any questions, please contact our support team for technical assistance at email@example.com.
For step-by-step instructions on creating the Worklet, see our user documentation: Create a Worklet.
Automox for Easy IT Operations
Automox is the cloud-native IT operations platform for modern organizations. It makes it easy to keep every endpoint automatically configured, patched, and secured – anywhere in the world. With the push of a button, IT admins can fix critical vulnerabilities faster, slash cost and complexity, and win back hours in their day.
Grab your free trial of Automox and join thousands of companies transforming IT operations into a strategic business driver.