Report of VM giving the status of patch orchestration mode used in the update manager

Varma 1,190 Reputation points
2024-02-25T07:31:55.0233333+00:00

Is there any PowerShell command to fetch the report of virtual machine with status of patch orchestration mode , for example below virtual machines are using automatic by OS and customer managed list. I am searching for an Excel report that contains information about the orchestration mode of virtual machines across their respective subscriptions. Thank you in Advance. For example you can see below: User's image

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,242 questions
Azure Update Manager
Azure Update Manager
An Azure service to centrally manages updates and compliance at scale.
247 questions
{count} votes

Accepted answer
  1. deherman-MSFT 33,861 Reputation points Microsoft Employee
    2024-02-26T21:45:14.4033333+00:00

    @Varma
    The recommended method is to utilize the Export to CSV portal option on the Azure Update Manager page. You can also customize the columns displayed under Settings.
    User's image

    If you must use PowerShell you can try this script to fetch the details:

    # Login to your Azure account
    Connect-AzAccount
    
    # Get all VMs in your Azure subscription
    $vms = Get-AzVM
    
    # Initialize an array to store custom objects
    $vmInfo = @()
    
    # Iterate through each VM
    foreach ($vm in $vms) {
        $vmName = $vm.Name
        $resourceGroupName = $vm.ResourceGroupName
        
        # Check if the OS is Linux or Windows and retrieve the patch settings accordingly
        if ($vm.StorageProfile.OsDisk.OsType -eq "Linux") {
            $patchMode = $vm.OSProfile.LinuxConfiguration.PatchSettings.PatchMode
            $enableAutomaticUpdates = $null  # For Linux VMs, automatic updates are not applicable
        }
        elseif ($vm.StorageProfile.OsDisk.OsType -eq "Windows") {
            $patchMode = $vm.OSProfile.WindowsConfiguration.PatchSettings.PatchMode
            $enableAutomaticUpdates = $vm.OSProfile.WindowsConfiguration.EnableAutomaticUpdates
        }
        
        # Create a custom object with the desired information
        $vmObject = [PSCustomObject]@{
            "VM Name" = $vmName
            "Resource Group" = $resourceGroupName
            "Patch Mode" = $patchMode
            "Enable Automatic Updates" = $enableAutomaticUpdates
        }
        
        # Add the custom object to the array
        $vmInfo += $vmObject
    }
    
    # Export the array to CSV format
    $vmInfo | Export-Csv -Path "VM_Info.csv" -NoTypeInformation
    
    

    Hope this helps! Let me know if you still have questions or issues.


    If you still have questions, please let us know in the "comments" and we would be happy to help you. Comment is the fastest way of notifying the experts. If the answer has been helpful, we appreciate hearing from you and would love to help others who may have the same question. Accepting answers helps increase visibility of this question for other members of the Microsoft Q&A community. Thank you for helping to improve Microsoft Q&A! User's image


0 additional answers

Sort by: Most helpful