Turn on the VM with Updates pending using Powershell

Abrar Adil S 216 Reputation points
2024-06-21T06:48:57.1066667+00:00

I have a PowerShell script that runs in an Automation Account to check for updates. To maintain compliance, I use the Azure Update Manager daily. However, when the Azure Update Manager runs during non-business hours, some VMs with pending updates are turned off.

I need a PowerShell script or command to get a list of VMs with pending updates, so I can turn on only those specific VMs from an Automation Account right before the Azure Update Manager schedule. This way, I can avoid turning on all servers, which would increase infrastructure costs.

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

1 answer

Sort by: Most helpful
  1. Stanislav Zhelyazkov 21,851 Reputation points MVP
    2024-06-21T09:44:27.8466667+00:00

    Hi,

    In order to scan for missing updates the machine needs to be running. There is no way that machines are turned off and you can scan for updates.

    Update 1:

    You can find some sample queries of how to get available updates in the official documentation. Keep in mind that the data is available for the past 30 days. If the machine was not started for more than 30 days the data will not be available. Information how to run resource graph queries with PowerShell.

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