MoonPoint Support Logo

 




Advanced Search
March
Sun Mon Tue Wed Thu Fri Sat
25
       
2026
Months
Mar
May Jun
Jul Aug Sep
Oct Nov Dec


Wed, Mar 25, 2026 4:39 pm

Ejecting a Disc with PowerShell

I needed to eject a optical disc drive tray from a command-line interface (CLI) on a system running Microsoft Windows 11 so that I could insert a DVD in the drive. That can be done using the Powershell command powershell (New-Object -ComObject WMPlayer.OCX.7).cdromCollection.item(0).Eject(), which will eject the tray of the first optical drive found by Windows Media Player's COM object.

PS C:\> powershell (New-Object -ComObject WMPlayer.OCX.7).cdromCollection.item(0).Eject()
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\>

[/os/windows/PowerShell] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo