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.

  1. On command prompt, type diskpart and wait for the new prompt, then type list volume. Take note of the number of your desired volume by watching its drive letter (be carefull!!!)
  2. Type select volume <number>, where is the number of your USB storage.
  3. Then, type remove all dismount. Type exit to leave diskpart. Enjoy! ;)
  4. 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):