{"id":225,"date":"2010-03-26T22:06:00","date_gmt":"2010-03-26T11:06:00","guid":{"rendered":"http:\/\/threemillion.net\/blog\/?p=225"},"modified":"2021-06-06T17:35:01","modified_gmt":"2021-06-06T07:35:01","slug":"remove-all-connected-cd-drives-and-isopaths","status":"publish","type":"post","link":"https:\/\/threemillion.net\/blog\/?p=225","title":{"rendered":"Remove all Connected CD Drives and IsoPaths"},"content":{"rendered":"<p>The following script gets all the VMs that have connected CD ROM drives and in addition it also picks up VMs that may not have CDs in a connected or connect at power on state, but do have something in the IsoPath. The reason I like to remove the IsoPath data as well is that I have a report that I run that lists the datastores that VMs are on. If a VM has data in the IsoPath for the CD ROM this is picked up by the report, which is not what I am after. That and it makes the environment nice and tidy. \ud83d\ude42<\/p>\n<pre><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\n#Create a list of VMs with CD drives connected or have data in the IsoPath\n$vmlist = Get-VM | ? { $_ | Get-CDDrive | ? { $_.ConnectionState.Connected -eq $true -or $_.IsoPath -ne $null } } | Sort\n#Set CD Drives to Client Device, removing the Connected status and deleting the IsoPath\n$vmlist | Get-CDDrive | Set-CDDrive -NoMedia -Confirm:$false\n<\/pre>\n<p>The same can be done for Floppy drives as well.<\/p>\n<pre><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\n#Create a list of VMs with CD drives connected or have data in the IsoPath\n$vmlist = Get-VM | ? { $_ | Get-FloppyDrive | ? { $_.ConnectionState.Connected -eq $true -or $_.FloppyImagePath -ne $null } } | Sort\n#Set CD Drives to Client Device, removing the Connected status and deleting the IsoPath\n$vmlist | Get-FloppyDrive | Set-FloppyDrive -NoMedia -Confirm:$false\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The following script gets all the VMs that have connected CD ROM drives and in addition it also picks up VMs that may not have CDs in a connected or <a href=\"https:\/\/threemillion.net\/blog\/?p=225\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":""},"categories":[8,18],"tags":[38,40,39,41],"_links":{"self":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/225"}],"collection":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=225"}],"version-history":[{"count":9,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/225\/revisions"}],"predecessor-version":[{"id":838,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/225\/revisions\/838"}],"wp:attachment":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}