I have to safely remove a USB device using a powershell script. Therefore I use following lines:
$drive= New-Object -comObject Shell.Application
$drive.Namespace(17).ParseName(<DRIVELETTER>).InvokeVerb("Eject")
The good thing is that Windows displays the popup that the USB can be removed and the device can´t be found any more with the explorer. The bad thing is that I still can find the ejected device with:
Get-WmiObject Win32_Volume -Filter "DriveType='2'" | Select-Object -ExpandProperty Caption
Does anybody have an idea to solve my issue?
For the sake of completeness: If I use the safely remove hardware function manually the device can´t be found with the Get-WmiObject function anymore.
Thanks for your help.