---
# source: blog-content: posts/en/powercli-find-and-disconnect-cd-drives-on-your-vms.md
# route:  /en/insights/powercli-find-and-disconnect-cd-drives-on-your-vms/
title: Find and disconnect CD Drives on your VMs
date: 2017-07-31
author: dario-doerflinger
locale: en
summary: One of the things that regularly pops up in our health checks in VMware environments are connected CD Drives that prevent DRS from functioning properly or prevents a host from entering maintenance
capabilities: [automation]
vendors: [vmware]
series: scripting
legacySlug: powercli-find-and-disconnect-cd-drives-on-your-vms
migrated: 2026-08-24
comments: 2
draft: false
---

One of the things that regularly pops up in our health checks in VMware environments are connected CD Drives that prevent DRS from functioning properly or prevents a host from entering maintenance mode when doing thing like patching.

In large environments it can get very tedious to disconnect all those drives manually. With PowerCLI it is just one line.

If you want to free up a host for maintenance mode you can do it with two lines:

```powershell
Get-VMHost <your host> |Get-VM | Where-Object {$_.PowerState -eq "PoweredOn"} | Get-CDDrive | Set-CDDrive -NoMedia -Confirm:$False
Get-VMHost <your host>| Set-VMHost -VMHost Host -State "Maintenance"
```

If you want to disconnect all of your CD-ROMs:

```powershell
Get-VM | Where-Object {$_.PowerState -eq "PoweredOn"} | Get-CDDrive | Set-CDDrive -NoMedia -Confirm:$False
```

If you just want to list all the VMs that have connected CD Drives:

```powershell
Get-VM | Where-Object {$_.PowerState -eq "PoweredOn"} | Get-CDDrive | FT Parent, IsoPath
```
