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.

Select-AzureSubscription -SubscriptionId xxxxxxx-xxxxxxxx-xxxxxx-xxxxxx
$VMlist = ForEach ($VM in (Get-AzureVM)) 
   {  Get-AzureOSDisk -VM $VM | Select @{Label="VM";Expression={$VM.Name}},`
                             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


Leave a Reply

Your email address will not be published. Required fields are marked *

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