Useful PowerCLI scripts

Print Friendly

Find VMs with snapshots

Connect-VIServer vcenter
Get-VM | Get-Snapshot | Select Created, VM

Find VMs with mounted ISO

Get-VM | FT Name, @{Label="ISO file"; Expression = { ($_ | Get-CDDrive).ISOPath }}

Get Datastores and Used Storage for VMs within Cluster

Get-Cluster "Cluster_name" | Get-VM | Select Name, @{N="Datastore";E={Get-Datastore -vm $_}}, UsedSpaceGB, ProvisionedSpaceGB  | sort Name | Export-Csv C:\datastores-acceptance.csv

Disconnect all VM CD-ROM Drives

get-cddrive -VM * |where {$_.ISOPATH -ne $null}|set-cddrive  -nomedia
This entry was posted in Virtualization. Bookmark the permalink.

Comments are closed.