PowerShell function to eject a drive
After you run the function Eject-Drive (either by pasting it directly into your terminal, or adding it to your $profile), you just run:
Eject-Drive D
to eject the D:\ drive. Replace D with whatever drive you want to eject.