PowerCLI: List all vm’s with ISO mounted and dismount them

Easy-peasy and a pretty short post…

To get all vm’s with iso mounted:

Get-VM | Get-CDDrive | select @{N="VM";E="Parent"},IsoPath | where {$_.IsoPath -ne $null}

Then, to dismount those:

Get-VM | Get-CDDrive | where {$_.IsoPath -ne $null} | Set-CDDrive -NoMedia -Confirm:$False

Category(s): PowerCLI, Powershell, VMware
Tags: , , , , ,

3 Responses to PowerCLI: List all vm’s with ISO mounted and dismount them

  1. Thanks a lot. Works like a charm!

  2. Here is another option to list all VM’s with a mounted ISO…

    Get-View -ViewType VirtualMachine | %{

    $name = $_.name

    $_.Config.Hardware.Device | where {$_ -is [vmware.vim.virtualcdrom]} | %{

    if($_.Connectable.Connected -eq $true){

    Write-Progress -Activity “Collecting VMs” -CurrentOperation $name

    $_ | Select-Object @{e={$Name};n=’ComputerName’},@{n=’Label’;e={$_.DeviceInfo.Label}},@{n=’Summary’;e={$_.DeviceInfo.Summary}}

    }

    }

    }

  3. I would recommend to add additional “-Connected $Falase” in Set-CDDrive

2 Responses in other blogs/articles

  1. […] For almost a year ago, I posted a simple one-liner to list all VMs who has ISOs mounted. You can view that post here: http://cloud.kemta.net/2013/10/powershell-vmware-list-all-vms-with-iso-mounted-and-dismount-them/ […]

  2. […] :Source: […]

Leave a Reply

Your email address will not be published. Required fields are marked *