You could use this REST API - Virtual Machines Run Commands - Run Command
to run Get-Service
in the VM, then you could get the services.
Request URL:
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand?api-version=2019-07-01
Request body:
{
"commandId": "RunPowerShellScript",
"script": [
"Get-Service"
]
}
When you call the REST API, you will get a 202
status code, there is no response in the body, you need to call another api in the Location
of the header to check the result, check my answer here .
Check the result via call another REST API:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.