← script library

Create VM List Report in VMware vSphere Using PowerShell

VMware & vSphereJanuary 6, 2025

In this post, I will share a PowerShell script designed to generate a report of all virtual machines (VMs) in your VMware vSphere environment. This report includes the VM names, statuses, and resource allocations, which can be extremely useful for inventory management and audits. The script assumes you have VMware PowerCLI installed and configured.

powershell
# Install VMware PowerCLI module
Install-Module -Name VMware.PowerCLI -AllowClobber -Force

# Connect to the vSphere server
$server = "your_vcenter_server"
$username = "username"
$password = "password"
Connect-VIServer -Server $server -User $username -Password $password

# Get all VM information
$vmList = Get-VM | Select-Object Name, PowerState, NumCPU, MemoryMB

# Export VM information to a CSV file
$vmList | Export-Csv -Path "C:\VM_Inventory_Report.csv" -NoTypeInformation
Write-Host "VM inventory report exported to C:\VM_Inventory_Report.csv"

# Disconnect from the vSphere server
Disconnect-VIServer -Server $server -Confirm:$false

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.