@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.
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!