PowerShell command to list the all virtual machines with status periodic assessment enabled or not

Varma 695 Reputation points
2024-02-06T06:24:30.4133333+00:00

PowerShell command to list the all virtual machines with status periodic assessment enabled or not from particular subscription If you have command please share , thank you

Azure Update Manager
Azure Update Manager
An Azure service to centrally manages updates and compliance at scale.
189 questions
0 comments No comments
{count} votes

Accepted answer
  1. Stanislav Zhelyazkov 19,126 Reputation points MVP
    2024-02-06T07:05:11.8966667+00:00

    Hi, I would suggest to use Azure Resource Graph for that. It will be faster and easier. Example query to use is :

    resources
    | where type =~ "microsoft.compute/virtualmachines" 
    |  where properties.storageProfile.osDisk.osType in~ ('Linux','Windows')
    | extend patchSettingsObject = iff(properties.storageProfile.osDisk.osType =~ "windows", properties.osProfile.windowsConfiguration.patchSettings, properties.osProfile.linuxConfiguration.patchSettings)
    | extend assessMode = tostring(patchSettingsObject.assessmentMode)
    | extend periodicAssessment = iff(isnotnull(assessMode) and assessMode =~ "AutomaticByPlatform", "Yes", "No")
    

    Keep in mind that the machine needs to be running otherwise it will give No on periodicAssessment result.

    Here is guide on how to use PowerShell with Azure Resource Graph.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


0 additional answers

Sort by: Most helpful