Skip to content

Instantly share code, notes, and snippets.

@jeffpatton1971
Created November 17, 2015 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffpatton1971/2ddcfb6b4a651513151b to your computer and use it in GitHub Desktop.
Save jeffpatton1971/2ddcfb6b4a651513151b to your computer and use it in GitHub Desktop.
A simple script to get the status of an Azure ARM vm
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