Forum Discussion
Gopalakrishnan S
Nov 30, 2017Copper Contributor
How do I list all VMs including creation date and drives list which attached and unattached
I want to list all the VMs ( all Resources Group) inside the azure with creation date, then all the Drives which I attached and unattached status.
Anyone one have the steps or any python script...
David Delorge
Dec 01, 2017Copper Contributor
This will get the Status and Details of all Vms in ARM
$RGs = Get-AzureRMResourceGroup
foreach($RG in $RGs)
{
$VMs = Get-AzureRmVM -ResourceGroupName $RG.ResourceGroupName
foreach($VM in $VMs)
{
$VMDetail = Get-AzureRmVM -ResourceGroupName $RG.ResourceGroupName -Name $VM.Name -Status
foreach ($VMStatus in $VMDetail.Statuses)
{
if($VMStatus.Code.CompareTo("PowerState/deallocated") -eq 0)
{
$VMStatusDetail = $VMStatus.DisplayStatus
}
}
write-output $VM.Name $VMStatusDetail
}
}