PowerTip: List Physical Drives with PowerShell

Doctor Scripto

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”

0 comments

Discussion is closed.

Feedback usabilla icon