-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgetvm.ps1
More file actions
42 lines (38 loc) · 753 Bytes
/
getvm.ps1
File metadata and controls
42 lines (38 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Param(
[string]$state="",
[string]$subname=""
)
function GetSubVms( $state )
{
if( $state -eq "" )
{
$vms = ( get-azurermvm )
}
else
{
$vms = ( get-azurermvm | where {$_.ProvisioningState -eq $state } )
}
Write-Host "# " $vms.Count
foreach( $vm in $vms )
{
Write-Host $vm.Name $vm.ProvisioningState $vm.StorageProfile.OSDisk.Vhd.Uri
}
}
if( $subname -eq "" )
{
$subs = get-azurermsubscription
foreach( $sub in $subs )
{
Write-Host
Write-Host $sub.SubscriptionName
select-azurermsubscription -SubscriptionId $sub.SubscriptionId
GetSubVms $state
}
}
else
{
Write-Host
Write-Host $subname
select-azurermsubscription -SubscriptionName $subname
GetSubVms $state
}