Code snippet – report VMs with CD-ROM/floppy and the device status

This script will report all VMs with a connected CD-ROM/floppy device (incl. information about the device status – eg. connected, connect at power on, client device,…)

Just fill in the name of your vCenter Server 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
}

Leave a Comment

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