
VMware PowerCLI command examples
Connect to vCenter Server (and linked vCenters)
1 |
Connect-VIServer -Server vc.server.local -Port 443 -User administrator@vsphere.local Password password123 -AllLinked -InvalidCertificateAction ignore |
List all Snapshots older than 14 days
1 |
Get-VM |Get-Snapshot | Where {$_.Created -lt (Get-Date).AddDays(-14)} |Select VM,Created,Name,SizeMB |FT |
List all powerred off VMs
1 |
Get-VM |Where-object {$_.powerstate -eq "poweredoff"} |
List all virtual disks pointing to an RDM device (and ignore errors)
1 |
Get-Datastore -WarningAction 0 | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select "Filename","CapacityKB" | fl |
Remove all CD/ISO from VMs
1 |
Get-VM | Get-CDDrive |Remove-CDDrive -Confirm:$false |
List all storage devices on specific host
1 |
Get-ScsiLun -VMhost 10.0.0.100 -LunType disk |Select CanonicalName,CapacityGB,MultipathPolicy |FT |
List all storage devices on all hosts
1 |
Get-VMHost |Get-ScsiLun -CanonicalName "*" -LunType disk |Select CanonicalName,CapacityGB,MultipathPolicy |FT |
List all paths to storage devices on specific host
1 |
Get-ScsiLun -VMhost 10.0.0.100 -LunType disk |Get-ScsiLunPath |Select Name,SanID,State |