Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Powershell - Eject USB device

$
0
0

As a bit of a challenge i was looking for the correct powershell code to eject a USB device.

Well this is it assuming your volume label is UUI

Powershell
$vol=get-wmiobject-ClassWin32_Volume|where{$_.label-eq'UUI'}$Eject=New-Object-comObjectShell.Application$Eject.NameSpace(17).ParseName($vol.driveletter).InvokeVerb(Eject)

If you google "eject usb device from powershell" you get to a topic on Spiceworks that talks about this but all that code actually do is to unassign the drive letter from the USB device so it doesn't really eject the device. This code does it. Just posted it here as i haven't yet figured out how to post a "How-To"


Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>