Tag Archives: dismount iso

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/ That post was written before I truly discovered the major advantages of using Get-View instead of Get-VM, Get-VMHost and so on. If used correctly, there’s a major difference in speed when using Get-View over Get-VM. When writing this post I checked the differences in speed when using the old way that I linked to above and my new function (which I’ll get to in a second or two..), the result was as follows: As you can see, the difference is pretty clear. 5 seconds vs. 1.6 minutes… So, without further ado, I present to you the code for Get-ISOMounts: function Get-ISOMounts { [CmdletBinding()] Param ( [switch]$Dismount ) $VMs = Get-View -ViewType virtualmachine -Property name,Config.Hardware.Device $VMsWithISO = @() $progress = 1 foreach ($VM in $VMs) { Write-Progress -Activity…

Read more

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