Tuesday, December 1, 2009

GetLogicalDisk

PowerShell can grab any logical drive from a remote computer using WMI and return a specific type.

ONELINER

gwmi Win32_LogicalDisk -Computername "%Remote_Computer%" -Filter "DriveType=3"

 code: copy : expand : collapse

EXPLANATION
Using Get-WMIObject we will connect to the WMI Class Win32_LogicalDisk and filter for only Local Disk (DriveType=3).

NOTE
You can filter by any drive type as listed below 0 = Unknown
1 = No Root Directory
2 = Removable Disk
3 = Local Disk
4 = Network Drive
5 = Compact Disc
6 = RAM Disk

ALIASES
GWMI = Get-WMIObject

0 comments: