How to loop through all the azure subscriptions in a powershell?
Hello SharePointers,
In this blog, I will share the script to loop through all the azure subscriptions in a tenant
$allResources = @()
$subscriptions=Get-AzureRMSubscription
ForEach ($vsub in $subscriptions){
Select-AzureRmSubscription $vsub.SubscriptionID
Write-Host
Write-Host “Working on “ $vsub
Write-Host
$allResources += $allResources |Select-Object $vsub.SubscriptionID,$vsub.Name
Get-AzureRmVM | Select Name,REsourceGroupName,Location
}
Happy SharePointing Folks 🙂