you can use PowerShell. Below are the steps to achieve this:
- Connect to Your Azure Account: Open a PowerShell window. Run the following command to sign in to your Azure account:
Connect-AzAccount
- Set the Subscription Context: Replace
'your_subscription_id'
with your actual subscription ID. Run the following command to set the subscription context:Set-AzContext -Subscription [ID]
- Get All VMs in the Subscription: Run the following command to retrieve all VMs in the subscription:
$vms = Get-AzVM
- Loop Through Each VM and Run the Script: Example loop:
foreach ( $vm in $vms) { $VMPatchResult = Invoke-AzVMPatchAssessment -ResourceGroupName $vm.ResourceGroupName -VMName $vm VMPatchAssessment += $VMPatchResult $VMPatchAssessment Export-Csv -Path .\Processes.csv } $VMPatchAssessment | Export-Csv -Path [PATH]
- Export the Results: You can export the results to a CSV file or any other format you prefer.
If the reply was helpful, please don’t forget to upvote or accept it as an answer, thank you!