Exporting details of Azure Virtual Machines to CSV/Excel

In my current role as a Cloud Solution Architect, I'm often asked to take a look at a customer's existing Azure environments and provide advice on how they can be improved. The first step is always to get an understanding of what it is that they've deployed. The Azure Portal provides a great exploration experience, but it's no good for more detailed analysis such as determining how many VMs there are of each size, how many are in availability sets, etc.

Fortunately you can get all of this information in PowerShell. However the commands are different for ARM and Classic VMs, and to pull all of the relevant information can take a few separate commands. After doing this manually for a few customers, I've written some reusable scripts that you can run against any Azure subscription. I've built two scripts, one for ARM and one for Classic, each of which runs against all of the subscriptions you have access to (or if you choose, just those tied to a specific Azure Active Directory tenant) and writes the info about each VM into a CSV file, ready to be loaded into Excel.

The scripts currently pull out the following info, but it should be easy to tweak if you need something different:

  • Subscription Name
  • Deployment model (ARM or Classic)
  • VM Name
  • Resource Group Name (ARM) or Cloud Service Name (Classic)
  • Location
  • VM Size
  • Status
  • Availability Set

Check out the scripts at the TechNet Script Center: