Created
November 17, 2015 16:12
-
-
Save jeffpatton1971/2ddcfb6b4a651513151b to your computer and use it in GitHub Desktop.
A simple script to get the status of an Azure ARM vm
This file contains hidden or 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
Param | |
( | |
[string]$Name | |
) | |
if ($Name) | |
{ | |
$VM = Get-AzureVM |Where-Object -Property Name -Like $Name |Get-AzureVM -Status |Select-Object -Property Name, ResourceGroupName, Statuses; | |
$vm.Statuses |ForEach-Object { | |
New-Object -TypeName psobject -Property @{ | |
Name = $VM.Name; | |
ResourceGroupName = $VM.ResourceGroupName; | |
Code = $_.Code; | |
DisplayStats = $_.DisplayStatus; | |
Level = $_.Level; | |
Message = $_.Message; | |
Time = $_.Time; | |
} | |
} | |
} | |
else | |
{ | |
Get-AzureVM |ForEach-Object { | |
$VM = Get-AzureVM -ResourceGroupName $_.ResourceGroupname -Name $_.Name -Status |Select-Object -Property Name, ResourceGroupName, Statuses; | |
$vm.Statuses |ForEach-Object { | |
New-Object -TypeName psobject -Property @{ | |
Name = $VM.Name; | |
ResourceGroupName = $VM.ResourceGroupName; | |
Code = $_.Code; | |
DisplayStats = $_.DisplayStatus; | |
Level = $_.Level; | |
Message = $_.Message; | |
Time = $_.Time; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment