Identifing, Unmounting CDs, and Rescanning the HBAs

with VMware PowerCLI

Posted by Scott Bollinger / @kfalconspb on February 09, 2014 #Virtualization

vMotion Failing?

These VMware PowerCLI commands, came in handy a month or so ago. I'd thought I'd share. Credit is given in the links below.

What do you do when, you see a mounted ISO not being used? Left abandoned and discarded? Does it drive you absolutely mad? Do you go all stabby Joe? Does the OCD kick in and you need to find and unmount the entire world. Then the below may help.

In all seriousness though, a mounted ISO will cause a vmotion to fail.

Thanks,

Scott Bollinger / @kfalconspb

Detect which VM’s have CDs mounted

Get-VM | Where-Object {$_ | Get-CDDrive | Where-Object { $_.ConnectionState.Connected -eq "true" } } | Select-Object Name

Detect which VM's have CDs mounted and unmount the ones found

Get-VM | Where-Object {$_ | Get-CDDrive | Where-Object { $_.ConnectionState.Connected -eq "true" } } | Get-CDDrive | Set-CDDrive -Connected $false -Confirm:$false

Rescan HBA’s in a cluster

Get-Cluster 'Cluster 1' | Get-VMHost | Get-VMHostStorage -RescanAllHba -RescanVmfs

Resources

  1. https://www.simple-talk.com/sysadmin/virtualization/10-steps-to-kick-start-your-vmware-automation-with-powercli/