MoonPoint Support Logo

 




Advanced Search
←November→
Sun Mon Tue Wed Thu Fri Sat
20 21
22 23 24 25 26 27 28
29 30          
←2026→
Months
NovDec


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