August 27th, 2013

PowerTip: Show attached USB Drives with PowerShell

Doctor Scripto
Scripter

Summary: Use Windows PowerShell to show attached USB drives.

Hey, Scripting Guy! Question Is there an easy way with Windows PowerShell to show all drives that are connected via USB?

Hey, Scripting Guy! AnswerUse Get-WMIObject and query win32_diskdrive:

GET-WMIOBJECT win32_diskdrive | Where { $_.InterfaceType –eq ‘USB’ }

Or…

Write this as a query and pass it directly to WMI:

GET-WMIOBJECT –query “SELECT * from win32_diskdrive where InterfaceType = ‘USB’”

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.