I’ll start by assuming that you already know how to install PowerCli.
If not, you can take a look on my older post [ here ]
In this post, I’ll explain how to list all the VMs in your Vcenter that have a mounted ISO image and how to dismount/disconnect this ISO using PowerCli.
So, let’s connect to the VCenter:
1 2 3 |
Import-Module VMware.PowerCLI Set-PowerCLIConfiguration -InvalidCertificateAction Ignore Connect-VIServer -Server vcenter.pbnet.local |
Now let’s list all the VMs that have an ISO image attached:
1 |
Get-VM | FT Name, @{Label="ISO file"; Expression = { ($_ | Get-CDDrive).ISOPath }} |
You’ll get a listing similar to the one below:
Name ISO file
—- ——–
EZCACTI [datastore1] ISOs/CactiEZ-v0.7.iso
OK, let’s dismount and disconnect this ISO from the “EZCACTI” VM:
1 2 |
PS C:\WINDOWS\system32> Get-VM -Name "EZCACTI" | Get-CDDrive | ?{$_.IsoPath -ne $null} | Set-CDDrive -NoMedia -Connected $false |
You can also use:
1 |
-Confirm:$False |
if you do not wish to confirm the action.
You can also dismount/disconnect all ISO files attached to all the machines:
1 |
Get-VM | Get-CDDrive | where {$_.IsoPath -ne $null} | Set-CDDrive -NoMedia -Connected $false -Confirm:$False |
Enjoy !