When is -gt 0 NOT -ne $null ?

Welcome Forums General PowerShell Q&A When is -gt 0 NOT -ne $null ?

Viewing 5 reply threads
  • Author
    Posts
    • #255914
      Participant
      Topics: 141
      Replies: 298
      Points: 526
      Rank: Major Contributor

      I ran some code yesterday that used this filter:

      …yet, when I ran today a different filter:

      ..it discovered some (much greater than 0) values.

      How should these strings be best Filtered for?

    • #255923
      Senior Moderator
      Topics: 9
      Replies: 1450
      Points: 5,434
      Helping Hand
      Rank: Community MVP

      0 and $null are not same, can you give lil more detail on against what cmdlet output you ran these fiilters and the difference in output in both.

    • #255929
      Participant
      Topics: 141
      Replies: 298
      Points: 526
      Rank: Major Contributor

      Sure, I was using Get-ADUser to search for values in the aforementioned attributes

    • #255947
      Senior Moderator
      Topics: 9
      Replies: 1450
      Points: 5,434
      Helping Hand
      Rank: Community MVP

      AFAIK both filter works differently here, Where-Objects takes the object once Get-ADUser executes per user where as the built-in Filter does it internally then give the output. What is the difference in output with both the approaches.

    • #255989
      Participant
      Topics: 141
      Replies: 298
      Points: 526
      Rank: Major Contributor

      It may be new values were added since last night by some other process but I cleared out those two attributes for all users that had them (via -ne $NULL discovery) and then today was alerted by a different Filter that there were others (although not near as many).

      I’ll check Monday using both filters and see what’s up in the environment.

    • #255992
      Participant
      Topics: 141
      Replies: 298
      Points: 526
      Rank: Major Contributor

      I have another Domain to test these 2 filters. Methinks there is a process populating the 2 attributes.

Viewing 5 reply threads
  • The topic ‘When is -gt 0 NOT -ne $null ?’ is closed to new replies.