August 29th, 2013

PowerTip: List Physical Drives with PowerShell

Doctor Scripto
Scripter

Summary: Use Windows PowerShell to list physical drives.

Hey, Scripting Guy! Question How can I use Windows PowerShell to get a list of physical drives?

Hey, Scripting Guy! Answer Use Get-WMIObject, query win32_logicaldisk, and filter with the DriveType property:

GET-WMIOBJECT –query “SELECT * from win32_logicaldisk where DriveType = ‘3’”

To check the drives on a remote computer, add the –ComputerName parameter.
For example, to list all physical drives and their free space on a machine called “ContosoWS1”:

GET-WMIOBJECT –query “SELECT * from win32_logicaldisk where DriveType = ‘3’”
–computername “ContosoWS1”

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.

Feedback