Forum Discussion
Sean145
Dec 24, 2024Copper Contributor
find the azure vm status in multiple subscription
We have multiple subscription (more than 10) in our environment and MFA enabled , I was trying to find one vm status using the name but its not working , setting azcontext with tenant ID also not wo...
luchete
Jan 22, 2025Iron Contributor
To manage VMs across multiple subscriptions, you need to first ensure you're authenticated and have access to all the subscriptions. You can use the Set-AzContext command to switch between them, but for querying across multiple subscriptions in a script, you can loop through all subscriptions using Get-AzSubscription and Set-AzContext within a script. Once the context is set for each subscription, you can use Get-AzVM to check the VM status. Make sure your account has sufficient permissions on each subscription and that MFA isn't blocking your access, otherwise you'll receive an error.
Hope it helps!