I am trying to filter out drives based on DeviceID, however its failing. When I try using DriveType its working fine.
For Example:
(Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType = 3 ")
Returns:
DeviceID : C:
DriveType : 3
ProviderName :
FreeSpace : 181411000320
Size : 255791026176
VolumeName :
However if I try using DeviceID:
(Get-WmiObject -Class Win32_LogicalDisk -Filter "DeviceID = C")
It returns:
(Get-WmiObject -Class Win32_LogicalDisk -Filter "DeviceID = C") Get-WmiObject : Invalid query "select * from Win32_LogicalDisk where DeviceID = C" At line:1 char:2 + (Get-WmiObject -Class Win32_LogicalDisk -Filter "DeviceID = C") + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-WmiObject], Management Exception + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C
ommands.GetWmiObjectCommand