Get all VMs using a certain datastore (in this case one with test in the name), and then show those that are powered off.
[vSphere PowerCLI] C:Program FilesVMwareInfrastructurevSphere PowerCLI> get-datastore -name "*test*" | get-vm | wher
e { $_.Powerstate -eq "poweredoff" }
Name PowerState Num CPUs Memory (MB)
---- ---------- -------- -----------
UPRINTXDM PoweredOff 1 2048
Uprint8_test PoweredOff 1 512
U-SANTEST-01 PoweredOff 1 512
U-SANTEST-02 PoweredOff 1 512
TestVM PoweredOff 1 512
uclh-test-vm02 PoweredOff 1 3840
Get all hosts in a cluster to rescan for new storage:
Get-Cluster | get-vmhost | Get-VMHostStorage -RescanAllHBA

