Azure VM PowerShell audit VHD disk information

I was having trouble getting a list of VHDs that are in use by my Azure VMs for OS and Data disks. I wanted to list them in a single line CSV to audit each VMs configuration. The issue was I had 3 commands with different objects:

Get-AzureVM

Get-AzureOSDisk

Get-AzureDataDisk

I wanted each output on the same line. I was able to rename the conflicting properties and output them to a single CSV, with each VM on a new line.

Output properties: Notice how I renamed conflicting disk properties to be prefixed with “Data” or “OS”.

AvailabilitySetName

DeploymentName

DNSName

InstanceSize

Name

DataDiskLabel

DataDiskName

DataDiskSizeGB

DataLUN

DataMediaLink

OS

OSDiskLabel

OSDiskName

OSMediaLink

Now I can look at VM Instance Size, Labels, OS/Data disk information, etc. and make any changes. Our team has about 40+ SharePoint development VMs in multiple cloud services, so provisioning/management can be a bit of work. In a perfect world I would use PowerShell DSC or Azure Automation, but that is quite a bit of work to setup for VMs we scrap every few months once projects are complete.

Next steps:

Split VMs into unique cloud services so multiple developers can start/stop VMs at the same time (worker process conflict) (using same site-to-site VPN)