Created
October 18, 2016 15:52
-
-
Save briglx/8d4eddd7de1647656df54120648b26ec to your computer and use it in GitHub Desktop.
List all VM on Azure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
$null = Get-AzureRmSubscription | |
} | |
catch { | |
Login-AzureRmAccount | |
} | |
$subscriptions = Get-AzureSubscription | |
$SubscriptionId="my-subscription-id" | |
$subscriptions = Get-AzureSubscription -SubscriptionId $SubscriptionId | |
Select-AzureSubscription -SubscriptionId $SubscriptionId –Default | |
# Look at asm VMs | |
"ASM VMS" | |
$vms = Get-AzureVM | |
Foreach($vm in $vms){ | |
$vm.Name | |
} | |
# List ARM Resource Groups | |
"ARM VMs" | |
$resourceGroups = Get-AzureRmResourceGroup | |
Foreach ($resourceGroup in $resourceGroups) { | |
$vms = Get-AzureRmVM -ResourceGroupName $resourceGroup."ResourceGroupName" | |
Foreach($vm in $vms){ | |
$vm.Name | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment