How do I list all VMs including creation date and drives list which attached and unattached

Occasional Visitor

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 scripts available? 

 

1 Reply

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
}
}