Freigeben über


Powershell Eject CD Drive

 

Awhile ago I wrote some code in AutoIT to Eject CD-Drives so that you wouldn’t get burnt in MDT/ConfigMgr while booting from Media.  Today I received a request for that code since the links at myITforum seem to be having some trouble.  While I was able to pull the original source code up it was time to modernize and simplify so here is the same code from a few years ago translated into Powershell for the few that might be interested.

$Eject = New-Object -ComObject "Shell.Application"
$Eject.Namespace(17).Items() |
    Where-Object { $_.Type -eq "CD Drive" } |
        foreach { $_.InvokeVerb("Eject") }

Disclaimer: The information on this site is provided "AS IS" with no warranties, confers no rights, and is not supported by the authors or Microsoft Corporation. Use of included script samples are subject to the terms specified
in the
Terms of Use .