Oneliner: Enumerate Local Drives, but NOT App-V 4 Virtual Drive Print E-mail
PowerShell
Written by Darwin Sanoy   
Thursday, April 23, 2015 7:37am

I had a need to list all local drives and went for the old fall back win32_logicaldisk, but I noticed it listed the App-V 4.6 virtual drive when scanning for type "3".

It also turns out that drive appears to have zero free space, so a slight modification eliminated that drive.

This is a case in point of using other attributes of a given item to filter out invalid targets.  It is important, however, not to guess that it will work for other challenges.  So does this approach work for other types of virtual drives - I won't know unless I test those specific drive types.

$localdrivesexceptappv = gwmi win32_logicaldisk | where {$_.DriveType -eq 3 -and $_.size -ne $null}