PowerCLI is the Swiss Army knife for VMware environments. Whether you’re automating routine tasks, generating compliance reports, or provisioning workloads at scale, PowerCLI enables you to script against vSphere, vCenter, and ESXi with precision and control.
In this first post of our modular PowerCLI series, we’ll walk through:
- PowerCLI installation
- Establishing secure vCenter/ESXi connections
- Querying vSphere inventory
- Running your first automation script
- Troubleshooting common startup issues
My Personal Repository on GitHub
Installing VMware PowerCLI
PowerCLI runs on PowerShell Core (cross-platform) or Windows PowerShell.
Windows / PowerShell Core (Recommended)
# Run as Administrator
Install-Module -Name VMware.PowerCLI -Scope CurrentUser -Force
# Disable certificate warning (optional in lab environments)
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
Notes
- PowerCLI 13+ supports REST bindings and NSX-T.
- You no longer need to install .NET or vSphere SDKs separately.
Connecting to vCenter or ESXi
Use Connect-VIServer to establish a secure session.
# Connect to vCenter
Connect-VIServer -Server "vcenter.lab.local" -User "admin@vsphere.local" -Password "YourPassword"
# Or connect directly to an ESXi host
Connect-VIServer -Server "esxi01.lab.local"
Authentication Tips
- Use a credential object for security:
$creds = Get-Credential
Connect-VIServer -Server "vcenter.lab.local" -Credential $creds
Exploring the Environment
Once connected, explore your inventory:
# List all VMs
Get-VM
# Get ESXi hosts
Get-VMHost
# Datastores
Get-Datastore
# Networks
Get-VirtualPortGroup
Sample Output:
Name PowerState Num CPUs MemoryGB
---- ---------- -------- --------
Web-01 PoweredOn 2 8.00
SQL-01 PoweredOff 4 16.00
Real-World Example: VM Inventory Report
This script generates a CSV report of all powered-on VMs with CPU and memory usage.
# Connect to vCenter first
$report = Get-VM | Where-Object {$_.PowerState -eq "PoweredOn"} | Select-Object Name, PowerState, NumCPU, MemoryGB, VMHost | Export-Csv -Path "C:\Reports\VM_Report.csv" -NoTypeInformation
Use case: Send to auditors or generate daily email reports via Task Scheduler.
Diagram: PowerCLI Workflow

Troubleshooting Connection Errors
| Issue | Fix |
|---|---|
Invalid server certificate | Set-PowerCLIConfiguration -InvalidCertificateAction Ignore |
Cannot load module | Run Update-Module VMware.PowerCLI or check PowerShell version |
403 Forbidden / Unauthorized | Check user role/permissions in vCenter or expired account |
Connect-VIServer fails silently | Use -Verbose to inspect connection pipeline |
What’s Next?
In the next article, we’ll explore how to use PowerCLI to:
- Query inventory with filters
- Generate custom HTML/CSV reports
- Export VM and host properties at scale