Here's a simple script to export all VMs from a specific resource group in Azure to a CSV file:
$ResourceGroupName = Read-Host "Enter the resource group name" $VMs = Get-AzVM -ResourceGroupName $ResourceGroupName $VMs | Select-Object Name, ResourceGroupName, Location, VMId, PowerState, OSProfile | `
Export-Csv -Path "$ResourceGroupName-VMsWithInfo.csv" -NoTypeInformation Write-Host "All VMs with VM information from resource group $ResourceGroupName exported to $ResourceGroupName-VMsWithInfo.csv"
Note: You'll need to have the Azure PowerShell module installed and authenticated to your Azure account before running this script. The script will prompt for the resource group name and will export the VM name, resource group name, location, VM ID, power state, and OS profile information for each VM in the specified resource group.
No comments:
Post a Comment