Hi Scott,
You can use these REST APIs to get the list of all the VMs.
Software Update Configurations - List - REST API (Azure Automation) | Microsoft Learn
Software Update Configurations - Get By Name - REST API (Azure Automation) | Microsoft Learn
PS Script:
$subscriptionId="xxxxxxxxx"
$resourceGroupName="xxxxxx"
$automationAccountName="xxxx"
$token="xxxxxxxxxxx"
$headers = @{
Authorization="Bearer $token"
}
$BaseUrl = "https://management.azure.com"
$Uri = "/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.Automation/automationAccounts/$automationAccountName/softwareUpdateConfigurations"
$ApiVersion = "?api-version=2019-06-01"
$sucsUrl = $BaseUrl + $Uri + $ApiVersion
$sucsResponseData = Invoke-RestMethod -Uri $sucsUrl -Method Get -Headers $headers
Write-Output "Total number of SUCs: " $sucsResponseData.value.Count
Foreach ($suc in $sucsResponseData.value) {
$sucUrl = $BaseUrl + $suc.id + $ApiVersion
$sucResponseData = Invoke-RestMethod -Uri $sucUrl -Method Get -Headers $headers
Write-Output "SUC name: " $sucResponseData.name
Write-Output "Azure Virtual Machines: " $sucResponseData.properties.updateConfiguration.azureVirtualMachines
Write-Output "Non-Azure Computer Names: " $sucResponseData.properties.updateConfiguration.nonAzureComputerNames
Write-Output "======================"
}