Site icon Digital Thought Disruption

Export a List of All VMs from vCenter with PowerCLI (Name, Host, IP, OS)

Introduction

Whether you are preparing for an audit, building an inventory system, or handing off documentation, exporting a list of all VMs is one of the most common tasks for any vSphere administrator. PowerCLI allows you to automate this process and include exactly the metadata your team or auditors need.

In this article, you will learn how to:


Step 1: Connect to vCenter and List All VMs

Connect-VIServer -Server "vcenter.lab.local"
Get-VM

Step 2: Create a Full VM Inventory Report

Get-VM | Select Name, PowerState, VMHost, @{N="IPAddress";E={$_.Guest.IPAddress}}, @{N="OS";E={$_.Guest.OSFullName}}, Notes

Step 3: Export to CSV

Get-VM | Select Name, PowerState, VMHost, @{N="IPAddress";E={$_.Guest.IPAddress}}, @{N="OS";E={$_.Guest.OSFullName}}, Notes | Export-Csv "C:\Reports\VM_Inventory.csv" -NoTypeInformation

Include date in the filename:

$timestamp = Get-Date -Format "yyyyMMdd"
Export-Csv -Path "C:\Reports\VM_Inventory_$timestamp.csv" -NoTypeInformation

Step 4: Filter by Folder or Cluster

Get-Folder -Name "Production" | Get-VM | Export-Csv "C:\Reports\Production_VMs.csv" -NoTypeInformation

Or by cluster:

Get-Cluster -Name "FinanceCluster" | Get-VM | Export-Csv "C:\Reports\FinanceCluster_VMs.csv" -NoTypeInformation

Step 5: Filter by Power State or Tag

Powered off only:

Get-VM | Where-Object {$_.PowerState -eq "PoweredOff"} | Export-Csv "C:\Reports\PoweredOffVMs.csv" -NoTypeInformation

By tag (e.g., “BackupEnabled”):

Get-TagAssignment -Tag "BackupEnabled" | Select Entity | Export-Csv "C:\Reports\TaggedVMs.csv" -NoTypeInformation

Diagram: VM Export Workflow with PowerCLI


Use Case: Monthly Reporting to Finance or Asset Team

You can create a reusable scheduled task that:


Bonus: Export to HTML for Browsing or Dashboards

Get-VM | Select Name, PowerState, VMHost, @{N="IPAddress";E={$_.Guest.IPAddress}}, @{N="OS";E={$_.Guest.OSFullName}} | ConvertTo-Html -Title "VM List" | Out-File "C:\Reports\VM_List.html"

Troubleshooting

IssueSolution
IP address field is emptyEnsure VMware Tools is running inside the guest
OS field shows “Other” or blankThe guest OS may be missing or not updated in vCenter
Exported CSV missing expected dataUse Select-Object with calculated properties explicitly
Notes field returns blankVerify that annotations are filled in on the VM summary page
Exit mobile version