我试图过滤出基于DeviceID的驱动器,但是它失败了。当我尝试使用DriveType时,它工作得很好。
例如:
(Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType = 3 ")返回:
DeviceID : C:
DriveType : 3
ProviderName :
FreeSpace : 181411000320
Size : 255791026176
VolumeName :但是,如果我尝试使用DeviceID:
(Get-WmiObject -Class Win32_LogicalDisk -Filter "DeviceID = C")它返回:
(Get-WmiObject -Class Win32_LogicalDisk -Filter "DeviceID = C") Get-WmiObject :无效查询"select * from Win32_LogicalDisk where = C“行:1字符:2+ (Get-WmiObject -Class Win32_LogicalDisk -Filter "DeviceID = C") ++ CategoryInfo : InvalidArgument:(:) Get-WmiObject,Management Exception + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C ommands.GetWmiObjectCommand
发布于 2018-01-04 08:46:47
这对我来说很管用:
(Get-WmiObject -Class Win32_LogicalDisk -Filter "DeviceID='C:'")看起来,您需要使用引号周围的驱动器字母和包括冒号。
https://stackoverflow.com/questions/48091342
复制相似问题