Introduction
Large enterprises often operate multiple vCenters across geographies or business units. Without a federated interface, managing them can be cumbersome. PowerCLI provides a way to automate configuration, audit, and reporting tasks across all vCenters simultaneously by chaining or parallelizing sessions.
In this article, you’ll learn how to:
- Connect to multiple vCenters in a single session
- Aggregate inventory and configuration data
- Normalize results across vCenters
- Execute changes conditionally by environment
- Export unified reports
Step 1: Define Multiple vCenter Targets
Create a credential object and define your targets:
$vCenters = @("vcenter-dfw.lab.local", "vcenter-nyc.lab.local", "vcenter-fra.lab.local")
$creds = Get-Credential
Step 2: Connect to All vCenters in One Session
$vCenters | ForEach-Object {
Connect-VIServer -Server $_ -Credential $creds
}
List all connected vCenters:
Get-VIServer
Step 3: Collect Inventory from All vCenters
Example: List all powered-on VMs globally
$globalVMs = @()
foreach ($vc in $vCenters) {
$globalVMs += Get-VM -Server $vc | Where-Object {$_.PowerState -eq "PoweredOn"}
}
$globalVMs | Select Name, PowerState, VMHost, @{N="vCenter";E={$_.Uid.Split("@")[1]}} | Export-Csv "C:\Reports\Global_VM_Inventory.csv" -NoTypeInformation
Step 4: Run Conditional Logic Per vCenter
Example: Only snapshot VMs in vCenter NYC
Connect-VIServer -Server "vcenter-nyc.lab.local" -Credential $creds
Get-VM | Where-Object {$_.Name -like "NYC-*"} | New-Snapshot -Name "NYC_Global_DR"
Step 5: Compare VM Counts by Site
$summary = @()
foreach ($vc in $vCenters) {
$vmCount = (Get-VM -Server $vc).Count
$summary += [PSCustomObject]@{
vCenter = $vc
VMCount = $vmCount
}
}
$summary | Export-Csv "C:\Reports\vCenter_VM_Counts.csv" -NoTypeInformation
Diagram: Multi-vCenter Aggregation Flow

Use Case: Unified Audit Across Business Units
Use PowerCLI to:
- Export VM tags, snapshots, and VMTools state per site
- Compare snapshot age and storage usage globally
- Share CSV with security or operations teams weekly
Common Gotchas and Fixes
| Problem | Fix |
|---|---|
| Get-VM fails on one vCenter | Ensure you’re specifying the -Server parameter in multi-session mode |
| Duplicate objects in export | Use Select-Object with -Unique or add a vCenter field manually |
| Disconnect-VIServer logs out all sessions | Use -Server parameter when disconnecting to keep other sessions open |
| Uid parsing fails | Use .ExtensionData.Client.ServiceUrl for precise vCenter reference |
Script Template: Full Multi-vCenter Reporting Engine
$vCenters = @("vcenter-dfw.lab.local", "vcenter-nyc.lab.local")
$creds = Get-Credential
$results = @()
foreach ($vc in $vCenters) {
Connect-VIServer -Server $vc -Credential $creds
$results += Get-VM -Server $vc | Select Name, PowerState, VMHost, @{N="vCenter";E={$vc}}
}
$results | Export-Csv "C:\Reports\MultiVC_VM_Export.csv" -NoTypeInformation
What’s Next
In the next article, we’ll explore:
- Automating content library management using PowerCLI
- Syncing templates, ISOs, and OVFs across sites