Replies: 1 comment 2 replies
-
MS graph user properties notoriously dont work with filtering on null values. If I was you I'd test using the MS Graph Explorer (Added a sample linked here) as this is what the PnP cmdlet is using behind the scenes and filtering uses the same syntax and then see if you custom property can be filtered for null. Believe the syntax could be: extension_b8fc35d8e8ec45e689d332303177957a_ZZZ_townCode ne null If not I think the next best way to do it would be retrieve all users like you are trying to avoid or have a regular scheduled process that writes the user data to another data source that can be filtered for null. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi experts,
how to use -Filter on a custom attribute against null values?
I am getting 'Invalid filter clause'
Example:
$users = Get-PnPAzureADUser -Select "DisplayName","extension_b8fc35d8e8ec45e689d332303177957a_ZZZ_townCode" -Filter "extension_b8fc35d8e8ec45e689d332303177957a_ZZZ_townCode -ne ''"
or
$users = Get-PnPAzureADUser -Select "DisplayName","extension_b8fc35d8e8ec45e689d332303177957a_ZZZ_townCode" -Filter "extension_b8fc35d8e8ec45e689d332303177957a_ZZZ_townCode -ne '$null'"
or
$users = Get-PnPAzureADUser -Select "DisplayName","extension_b8fc35d8e8ec45e689d332303177957a_ZZZ_townCode" -Filter "extension_b8fc35d8e8ec45e689d332303177957a_ZZZ_townCode -ne $null"
This is working, but I don't want to fetch all user first:
$users = Get-PnPAzureADUser -Select "DisplayName","extension_b8fc35d8e8ec45e689d332303177957a_ZZZ_townCode" | Where-Object { $_.AdditionalProperties["extension_b8fc35d8e8ec45e689d332303177957a_ZZZ_townCode"] -ne $null }
Thx, Ronny
Beta Was this translation helpful? Give feedback.
All reactions