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

5 comments on “PowerCLI: List all vm’s with ISO mounted and dismount them

  1. 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}}

    }

    }

    }

Leave a Reply

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