wmiobject Filter not working

Welcome Forums General PowerShell Q&A wmiobject Filter not working

Viewing 2 reply threads
  • Author
    Posts
    • #42533
      Participant
      Topics: 1
      Replies: 0
      Points: 0
      Rank: Member

      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
      Participant
      Topics: 5
      Replies: 322
      Points: 444
      Helping Hand
      Rank: Contributor

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

      get-wmiobject -class win32_logicaldisk -filter "deviceid='c:'"
    • #42539
      Participant
      Topics: 0
      Replies: 669
      Points: 0
      Rank: Member

      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 2 reply threads
  • The topic ‘wmiobject Filter not working’ is closed to new replies.