This script will report all VMs with a connected CD-ROM/floppy device. It will give you information about the device status – e.g. connected, connect at power on, client device

Replace vCenter Server with your vCenter Server name in the first line:

Connect-VIServer vCenter_name

$vms = Get-VM

write “VMs with a connected CD-ROM:”

foreach ($vm in $vms | where { $_ | Get-CDDrive | where { $_.ConnectionState.Connected -eq “true”}}) {

write $vm.name

}

write “VMs with CD-ROM connected at power on:”

foreach ($vm in $vms | where { $_ | Get-CDDrive | where { $_.ConnectionState.StartConnected -eq “true”}}) {

write $vm.name

}

write “VMs with CD-ROM connected as ‘Client Device’:”

foreach ($vm in $vms | where { $_ | Get-CDDrive | where { $_.RemoteDevice.Length -ge 0}}) {

write $vm.name

}

write “VMs with CD-ROM connected to ‘Datastore ISO file’:”

foreach ($vm in $vms | where { $_ | Get-CDDrive | where { $_.ISOPath -like “*.ISO*”}}) {

write $vm.name

}

write “VMs with connected Floppy:”

foreach ($vm in $vms | where { $_ | Get-FloppyDrive | where { $_.ConnectionState.Connected -eq “true”}}) {

write $vm.name

}

write “VMs with floppy connected at power on:”

foreach ($vm in $vms | where { $_ | Get-FloppyDrive | where { $_.ConnectionState.StartConnected -eq “true”}}) {

write $vm.name

}

write “VMs with floppy connected as ‘Client Device’:”

foreach ($vm in $vms | where { $_ | Get-FloppyDrive | where { $_.RemoteDevice.Length -ge 0}}) {

write $vm.name

}

Note: Copy this code in a notepad and save the file as .ps1

Posted in: Vmware.
Last Modified: January 12, 2017

Leave a reply