Classic Azure VM Details

Azure VM Details

I was looking for a way to have a list with Azure VM Details of Azure Classic deployment. Some of the details are VM Name, HostName, Service Name, IP address, Instance Size, Availability Set, Operating System, Disk Name (OS), SourceImageName (OS), MediaLink (OS), HostCaching (OS), Subnet, DataDisk Name, DataDisk HostCaching, DataDisk MediaLink, DataDisk Size.

 

Lets start. The first step wat to open PowerShell ISE, search some technet articles and after a lot of test I created the below script.

Add-AzureAccount
Select-AzureSubscription -SubscriptionId xxxxxxx-xxxxxxxx-xxxxxx-xxxxxx
$VMlist = ForEach ($VM in (Get-AzureVM)) 
   {  Get-AzureOSDisk -VM $VM | Select @{Label="VM";Expression={$VM.Name}},`
                             @{Label="HostName";Expression={$VM.HostName}},`
                             @{Label="Service";Expression={$VM.ServiceName}},`
                             @{Label="IP";Expression={$VM.IpAddress}},`
                             @{Label="InstanceSize";Expression={$VM.InstanceSize}},`
                             @{Label="AvailabilitySet";Expression={$VM.AvailabilitySetName}},`
                             OS,DiskName,SourceImageName,MediaLink,HostCaching, `
                             @{Label="Subnet";Expression={(Get-AzureSubnet -VM $VM)}},`
                             @{Label="DataDiskName";Expression={(Get-AzureDataDisk -VM $VM).DiskName}},`
                             @{Label="DDHostCaching";Expression={(Get-AzureDataDisk -VM $VM).HostCaching}},`
                             @{Label="DDMediaLink";Expression={(Get-AzureDataDisk -VM $VM).MediaLink}},`
                             @{Label="DDSize";Expression={(Get-AzureDataDisk -VM $VM).LogicalDiskSizeInGB}}
   } 
$VMlist | Sort VM,SourceImageName | Export-CSV C:\vms_alldata.csv -NoTypeInformation

Next, just open the vms_alldata.csv with Excel, convert test to columns and insert table and voila:

azure vm details

Share

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.