VMware PowerCLI Identifing, Unmounting CDs, and Rescanning the HBAs

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

Hopefully that’s how attribution is given. Hmm better research that. 😉

What do you do when you see a mounted ISO not being used? Left abandoned like a discarded cigarette in a urinal? 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.

Thanks,

Scott Bollinger / kfalconspb / www.bollingerusa.com

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/

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s