Created
July 3, 2017 22:26
-
-
Save atao/a21336b94f093296522ab72de04f51c8 to your computer and use it in GitHub Desktop.
Just eject CD drives!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Eject-CD | |
{ | |
$drives = Get-WmiObject Win32_Volume -Filter "DriveType=5" | |
if ($drives -eq $null) | |
{ | |
Write-Warning "Your computer has no CD drives to eject." | |
return | |
} | |
$drives | ForEach-Object { | |
(New-Object -ComObject Shell.Application).Namespace(17).ParseName($_.Name).InvokeVerb("Eject") | |
} | |
} | |
Eject-CD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment