Welcome › Forums › General PowerShell Q&A › When is -gt 0 NOT -ne $null ?
- This topic has 5 replies, 2 voices, and was last updated 4 months, 2 weeks ago by
Participant.
-
AuthorPosts
-
-
September 11, 2020 at 2:44 pm #255914
I ran some code yesterday that used this filter:
PowerShell1Where-Object { $_.delivContLength -ne $null -or $_.submissionContLength -ne $null }…yet, when I ran today a different filter:
PowerShell1-Filter {(delivContlength -gt 0)-or(submissionContLength -gt 0)}..it discovered some (much greater than 0) values.
How should these strings be best Filtered for?
-
September 11, 2020 at 3:05 pm #255923
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.
-
September 11, 2020 at 3:11 pm #255929
Sure, I was using Get-ADUser to search for values in the aforementioned attributes
-
September 11, 2020 at 3:23 pm #255947
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.
-
September 11, 2020 at 5:46 pm #255989
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.
-
September 11, 2020 at 6:00 pm #255992
I have another Domain to test these 2 filters. Methinks there is a process populating the 2 attributes.
PowerShell12345PS C:\> ($UserREQ1).Count12PS C:\> ($UserREQ1_filter2).Count12
-
-
AuthorPosts
- The topic ‘When is -gt 0 NOT -ne $null ?’ is closed to new replies.