Quick reference
Module (vSphere 9 / VCF 9)
VCF.PowerCLIModule (vSphere 7 and 8)
VMware.PowerCLIInstall
Install-Module VCF.PowerCLIConnect
Connect-VIServer vcenter.example.comActive connections
$global:DefaultVIServersDisconnect
Disconnect-VIServer -Server * -Confirm:$false
Which module: Broadcom renamed the module from
VMware.PowerCLI to VCF.PowerCLI with VCF PowerCLI 9.0 in June 2025. The guidance is to uninstall the old module and install the new one rather than upgrade in place. PowerCLI 13.3 and earlier run on Windows PowerShell 5.1 or PowerShell 7.x; Broadcom now names PowerShell 7.4 as the minimum recommended version and is phasing 5.1 out.
Install and connect
| Task | Command |
|---|---|
| Install from PowerShell Gallery | Install-Module -Name VCF.PowerCLI -Scope CurrentUser |
| Update | Update-Module -Name VCF.PowerCLI |
| Verify it is present | Get-Module -Name VCF.PowerCLI -ListAvailable |
| Install alongside an old VMware.PowerCLI | Install-Module VCF.PowerCLI -AllowClobber -SkipPublisherCheck |
| Accept a self-signed vCenter certificate | Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false |
| Turn off the CEIP prompt | Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false -Confirm:$false |
| Show current configuration | Get-PowerCLIConfiguration |
| Connect with a prompt for credentials | Connect-VIServer vcenter.example.com -Credential (Get-Credential) |
| Connect and store the credential | Connect-VIServer vcenter.example.com -SaveCredentials |
| Connect to several vCenters | Connect-VIServer vc01, vc02 |
| Disconnect from all | Disconnect-VIServer -Server * -Confirm:$false |
SkipPublisherCheck: Broadcom signs the module with its own certificate instead of the old VMware one. Without
-SkipPublisherCheck the install can fail on a machine that still has modules signed by VMware.
Find things in the inventory
| Task | Command |
|---|---|
| All VMs | Get-VM |
| One VM | Get-VM -Name web01 |
| VMs by name pattern | Get-VM -Name "web*" |
| Powered-on VMs only | Get-VM | Where-Object {$_.PowerState -eq 'PoweredOn'} |
| VMs on one host | Get-VMHost esx01.example.com | Get-VM |
| VMs in one cluster | Get-Cluster PROD | Get-VM |
| All hosts | Get-VMHost |
| Clusters, datacenters, folders | Get-Cluster · Get-Datacenter · Get-Folder |
| Datastores | Get-Datastore |
| Resource pools | Get-ResourcePool |
| Everything a VM is made of | Get-VM web01 | Format-List * |
| Guest OS details (needs VMware Tools) | Get-VMGuest -VM web01 |
Pipelines are the point: Almost every
Get- cmdlet accepts objects from another. Get-Cluster PROD | Get-VMHost | Get-VM reads left to right and needs no loops.
VM power and lifecycle
| Task | Command |
|---|---|
| Power on | Start-VM -VM web01 |
| Graceful guest shutdown | Shutdown-VMGuest -VM web01 -Confirm:$false |
| Hard power off | Stop-VM -VM web01 -Confirm:$false |
| Restart the guest OS | Restart-VMGuest -VM web01 -Confirm:$false |
| Suspend | Suspend-VM -VM web01 -Confirm:$false |
| Create a VM | New-VM -Name web02 -VMHost esx01 -Datastore ds01 -NumCpu 2 -MemoryGB 4 -DiskGB 40 |
| Clone from a template | New-VM -Name web03 -Template tpl-2022 -VMHost esx01 -Datastore ds01 |
| vMotion to another host | Move-VM -VM web01 -Destination esx02 |
| Storage vMotion | Move-VM -VM web01 -Datastore ds02 |
| Delete from disk | Remove-VM -VM web01 -DeletePermanently -Confirm:$false |
Stop-VM is the power cable:
Stop-VM cuts power with no guest shutdown. Use Shutdown-VMGuest for anything with a running OS, and keep Stop-VM for a guest that has already stopped responding.
VM configuration
| Task | Command |
|---|---|
| Change CPU and memory | Set-VM -VM web01 -NumCpu 4 -MemoryGB 8 -Confirm:$false |
| List disks | Get-HardDisk -VM web01 |
| Add a thin disk | New-HardDisk -VM web01 -CapacityGB 100 -StorageFormat Thin |
| Grow a disk | Get-HardDisk -VM web01 | Where-Object {$_.Name -eq "Hard disk 2"} | Set-HardDisk -CapacityGB 200 -Confirm:$false |
| List network adapters | Get-NetworkAdapter -VM web01 |
| Move an adapter to another port group | Get-NetworkAdapter -VM web01 | Set-NetworkAdapter -NetworkName "VLAN10" -Confirm:$false |
| Mount an ISO | Get-CDDrive -VM web01 | Set-CDDrive -IsoPath "[ds01] iso/win.iso" -Connected $true -Confirm:$false |
| Disconnect the CD drive | Get-CDDrive -VM web01 | Set-CDDrive -NoMedia -Confirm:$false |
| Upgrade VMware Tools | Update-Tools -VM web01 |
Snapshots
| Task | Command |
|---|---|
| List a VM snapshots | Get-Snapshot -VM web01 |
| Every snapshot in the environment | Get-VM | Get-Snapshot |
| Snapshots older than seven days | Get-VM | Get-Snapshot | Where-Object {$_.Created -lt (Get-Date).AddDays(-7)} |
| Total space used by snapshots | Get-VM | Get-Snapshot | Measure-Object -Property SizeGB -Sum |
| Create | New-Snapshot -VM web01 -Name "pre-patch" -Description "before September patching" |
| Create with a quiesced filesystem | New-Snapshot -VM web01 -Name "pre-patch" -Quiesce |
| Delete one | Get-Snapshot -VM web01 -Name "pre-patch" | Remove-Snapshot -Confirm:$false |
| Delete a snapshot and its children | Get-Snapshot -VM web01 -Name "pre-patch" | Remove-Snapshot -RemoveChildren -Confirm:$false |
| Revert | Set-VM -VM web01 -Snapshot "pre-patch" -Confirm:$false |
Snapshots are not backups: A snapshot grows a delta file for as long as it exists and consolidation gets slower the longer you wait. The aging query above is the one worth putting in a scheduled report.
Hosts and clusters
| Task | Command |
|---|---|
| Host summary | Get-VMHost | Select-Object Name,ConnectionState,PowerState,Version,Build |
| Enter maintenance mode | Set-VMHost -VMHost esx01 -State Maintenance -Confirm:$false |
| Leave maintenance mode | Set-VMHost -VMHost esx01 -State Connected -Confirm:$false |
| Reboot a host | Restart-VMHost -VMHost esx01 -Confirm:$false |
| Host services | Get-VMHostService -VMHost esx01 |
| Start SSH on a host | Get-VMHostService -VMHost esx01 | Where-Object {$_.Key -eq 'TSM-SSH'} | Start-VMHostService |
| Rescan all HBAs | Get-VMHostStorage -VMHost esx01 -RescanAllHba |
| Hardware inventory | Get-VMHost esx01 | Get-VMHostHardware |
| Cluster settings | Get-Cluster | Select-Object Name,HAEnabled,DrsEnabled,DrsAutomationLevel |
| Run esxcli against a host | $e = Get-EsxCli -VMHost esx01 -V2 then $e.system.version.get.Invoke() |
Get-EsxCli -V2: Always pass
-V2. The version 1 interface is positional and breaks silently when a namespace changes between ESXi releases; V2 takes a named argument hashtable from $e.<namespace>.CreateArgs().
Storage and datastores
| Task | Command |
|---|---|
| Datastore usage | Get-Datastore | Select-Object Name,@{N="FreeGB";E={[math]::Round($_.FreeSpaceGB)}},@{N="TotalGB";E={[math]::Round($_.CapacityGB)}} |
| Which VMs live on a datastore | Get-Datastore ds01 | Get-VM |
| Datastore clusters | Get-DatastoreCluster |
| Host storage view | Get-VMHostStorage -VMHost esx01 |
| Thin-provisioned disks | Get-VM | Get-HardDisk | Where-Object {$_.StorageFormat -eq 'Thin'} |
| Browse a datastore | New-PSDrive -Name ds -PSProvider VimDatastore -Root "\\" -Location (Get-Datastore ds01) |
Networking
| Task | Command |
|---|---|
| Standard switches on a host | Get-VirtualSwitch -VMHost esx01 |
| Port groups | Get-VirtualPortGroup -VMHost esx01 |
| Physical and VMkernel adapters | Get-VMHostNetworkAdapter -VMHost esx01 |
| Distributed switches | Get-VDSwitch |
| Distributed port groups | Get-VDPortgroup |
| Which VMs use a port group | Get-VM | Get-NetworkAdapter | Where-Object {$_.NetworkName -eq "VLAN10"} |
| VMkernel addresses | Get-VMHostNetworkAdapter -VMHost esx01 -VMKernel | Select-Object Name,IP,SubnetMask,Mtu |
Reporting, events and performance
| Task | Command |
|---|---|
| VM inventory to CSV | Get-VM | Select-Object Name,PowerState,NumCpu,MemoryGB,@{N="UsedGB";E={[math]::Round($_.UsedSpaceGB)}} | Export-Csv vms.csv -NoTypeInformation |
| Recent vCenter events | Get-VIEvent -MaxSamples 100 |
| Events for one VM | Get-VM web01 | Get-VIEvent -MaxSamples 50 |
| Who powered off a VM | Get-VM web01 | Get-VIEvent -Types Info | Where-Object {$_.FullFormattedMessage -match "power"} |
| Live CPU statistics | Get-Stat -Entity (Get-VM web01) -Stat cpu.usage.average -Realtime -MaxSamples 10 |
| Host memory over the last day | Get-Stat -Entity (Get-VMHost esx01) -Stat mem.usage.average -Start (Get-Date).AddDays(-1) |
| VMware Tools status everywhere | Get-VM | Select-Object Name,@{N="Tools";E={$_.ExtensionData.Guest.ToolsStatus}} |
Reaching further: When no cmdlet exposes a property,
Get-VM web01 | Get-View returns the underlying managed object, and $vm.ExtensionData reaches the same data from an object you already have.
FAQ
Should I install VMware.PowerCLI or VCF.PowerCLI?
Use
VCF.PowerCLI for VMware Cloud Foundation 9 and vSphere 9. Keep VMware.PowerCLI 13.x for vSphere 7 and 8 estates that have not moved yet. Broadcom advises uninstalling the old module before installing the new one rather than upgrading over the top, because duplicate cmdlet names cause conflicts.
Do I need PowerShell 7?
PowerCLI 13.3 and earlier work on Windows PowerShell 5.1 as well as PowerShell 7.x. Broadcom now names PowerShell 7.4 as the minimum recommended version and is phasing out 5.1 support, so new automation is worth writing on 7.x. On Linux and macOS PowerShell 7 has always been the only option.
Connect-VIServer fails with a certificate error
vCenter ships with a self-signed certificate that PowerShell does not trust. Either install the vCenter root certificate on the machine running PowerCLI, or set
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false. The first is correct for anything scheduled; the second is fine on an admin workstation.
A cmdlet keeps asking for confirmation
Most cmdlets that change state have a confirmation prompt. Add
-Confirm:$false per command, or set it once for the session with Set-PowerCLIConfiguration -Confirm:$false. Do not put that in a script somebody else will run.
How do I run an esxcli command through PowerCLI?
Get a handle with
$e = Get-EsxCli -VMHost esx01 -V2, then call the namespace path as a method, for example $e.network.nic.list.Invoke(). Arguments go in a hashtable built by $e.<namespace>.CreateArgs().