wmiobject Filter not working

This topic contains 2 replies, has 3 voices, and was last updated by Profile photo of Richard Siddaway Richard Siddaway 3 months, 2 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #42533
    Profile photo of Srikanth Byragoni
    Srikanth Byragoni
    Participant

    Hi

    I am trying to execute the below given code, but its giving an error message
    get-wmiobject -class win32_logicaldisk -filter "deviceid=c:"

    #42537
    Profile photo of random commandline
    random commandline
    Participant

    Use Get-Help Get-WmiObject -Parameter filter for more info

    get-wmiobject -class win32_logicaldisk -filter "deviceid='c:'"
    #42539

    Should be
    Get-WmiObject -Class Win32_LogicalDisk -Filter "DeviceId='C:'"

    When you create a filter the value you're testing has to be in quotes if it's a string value

    (Get-CimClass -ClassName Win32_LogicalDisk).CimClassProperties['DeviceId']

    Name : DeviceID
    Value :
    CimType : String
    Flags : Property, Key, ReadOnly, NullValue
    Qualifiers : {CIM_Key, read, key, MappingStrings...}
    ReferenceClassName :

    Same applies to Get-CimInstance
    Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DeviceId='C:'"

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.