[BUG] Sync-PnPSharePointUserProfilesFromAzureActiveDirectory produces different JSON when passing Users to the Function
Reporting an Issue or Missing Feature
When using Sync-PnPSharePointUserProfilesFromAzureActiveDirectory, the JSON generated in the document library does not contain all Properties when passing in Users. If the users parameter is not used, the JSON is generated correctly.
Expected behavior
When passing users, the JSON should contain all Properties defined in the UserProfilePropertyMapping parameter.
Actual behavior
When passing users, the JSON does not contain all Properties defined in the UserProfilePropertyMapping parameter.
Steps to reproduce behavior
- Connect to a SharePoint site with Connect-PnPOnline
- Run the command: Sync-PnPSharePointUserProfilesFromAzureActiveDirectory -UserProfilePropertyMapping @{'SPS-Department'= 'Department';'FirstName'='GivenName';'LastName'='sn'; 'Department'='Department'; 'Manager'='Manager'} -Folder "
" -WhatIf - JSON with all properties{ "value": [
"IdName":"
","Manager":"","SPS-Department":"","FirstName":"","Department":"" ]} - Get Users from Azure AD: $users = Get-PnPAzureADUser
- Run Command again with users: Sync-PnPSharePointUserProfilesFromAzureActiveDirectory -UserProfilePropertyMapping @{'SPS-Department'= 'Department';'FirstName'='GivenName';'LastName'='sn'; 'Department'='Department'; 'Manager'='Manager'} -Folder "Freigegebene Dokumente" -Users $users -WhatIf
- JSON with missing properties{ "value": [
"IdName":"
","FirstName":"" ]}
What is the version of the Cmdlet module you are running?
PnP.PowerShell 2.2.0
Which operating system/environment are you running PnP PowerShell on?
- [X] Windows
- [ ] Linux
- [ ] MacOS
- [ ] Azure Cloud Shell
- [ ] Azure Functions
- [ ] Other : please specify
Having a quick look at the code with regards to what you're reporting here, it feels like the case must be that the users you are passing in using -Users do not contain the properties which you are missing in the JSON. Is this possible? If you don't provide users yourself, it will fetch all the properties matching the ones in -UserProfilePropertyMapping from AAD itself. If you pass in Users, it will assume you took care of passing in all the right properties. It double checks when creating the JSON that you actually did do so and if not, it will omit them in the JSON. It feels like this is your scenario. Can you validate this?
Closing it due to lack of response, feel free to reopen this with more information, thanks !