Eject connected external hard drive using cmd
You can use command below and consider changing the ParseName
parameter with your drive letter
Single line using the Run dialog or CMD:
powershell (New-Object -comObject Shell.Application).Namespace(17).ParseName(\"E:\").InvokeVerb(\"Eject\")
Using PowerShell
powershell (New-Object -comObject Shell.Application).Namespace(17).ParseName("E:").InvokeVerb("Eject")
it seems that, below option in some cases only remove the drive latter.
Use the diskpart utility to safely remove a disk drive. This is useful when you have no GUI, for example in Server Core or Hyper-V Server.
- On command prompt, type
diskpart
and wait for the new prompt, then typelist volume
. Take note of the number of your desired volume by watching its drive letter (be carefull!!!) - Type
select volume <number>
, where is the number of your USB storage. - Then, type
remove all dismount
. Typeexit
to leave diskpart. Enjoy! ;) - Now you can safely remove your USB storage device from the Hyper-V server.
According to the diskpart remove's help (type "help remove" inside diskpart):