This is a quick blog post on how to report on VMs connected with ISO or CD Drive. Refer to my previous post on how remove ISO or cd-drive from VMs in your vmware estate.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ## VMware Find VMs with ISO Connected param ( [ Parameter ( Mandatory = $true )] [VMware.VimAutomation.ViCore.Types.V1.Inventory.Cluster] $vParam ); [Array] $vmList = @( Get-VM -Location $vParam | Sort Name ); foreach ( $vmItem in $vmList ) { [Array] $vmCdDriveList = @( Get-CDDrive -VM $vmItem ); foreach ( $vmCdDriveItem in $vmCdDriveList ) { [String] $insertedElement = " "; [String] $connectionType = ""; switch ( $vmCdDriveItem ) { { $_.IsoPath } { $insertedElement = $_.IsoPath; $connectionType = " ISO "; break; } { $_.HostDevice } { $insertedElement = $_.HostDevice; $connectionType = " Host Device "; break; } { $_.RemoteDevice } { $insertedElement = $_.RemoteDevice; $connectionType = " Remote Device "; break; } default { $insertedElement = " None "; $connectionType = " Client Device "; break; } } $output = New-Object -TypeName PSObject; $output | Add-Member -MemberType NoteProperty -Name " VM " -Value $vmItem $output | Add-Member -MemberType NoteProperty -Name " CD-Drive " -Value $vmCdDriveItem.Name; $output | Add-Member -MemberType NoteProperty -Name " Connection " -Value $connectionType; $output | Add-Member -MemberType NoteProperty -Name " Inserted " -Value $insertedElement; $output | Add-Member -MemberType NoteProperty -Name " Connected " -Value $vmCdDriveItem.ConnectionState.Connected; $output | Add-Member -MemberType NoteProperty -Name " StartConnected " -Value $vmCdDriveItem.ConnectionState.StartConnected; $output | Add-Member -MemberType NoteProperty -Name " AllowGuestControl" -Value $vmCdDriveItem .ConnectionState.AllowGuestControl; $output ; } } |