In case it helps anyone else… I needed to create a list of all the VMs across all my Azure subscriptions and put into a CSV file (so I can add to Excel, do a VLOOKUP
, etc.)
1 2 3 4 5 6 7 8 9 |
Get-AzSubscription | ForEach-Object{ Set-AzContext -Subscription $_.Name | Out-Null foreach ($VM in Get-AzVM) { [PSCustomObject]@{ VM = $VM.Name Subscription = $_.Name } } } | Export-Csv ~\path\to\VMList.csv -Force -NoTypeInformation |