powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[BUG] Sync-PnPSharePointUserProfilesFromAzureActiveDirectory produces different JSON when passing Users to the Function

Open FreakIsTea opened this issue 3 years ago • 2 comments

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

  1. Connect to a SharePoint site with Connect-PnPOnline
  2. Run the command: Sync-PnPSharePointUserProfilesFromAzureActiveDirectory -UserProfilePropertyMapping @{'SPS-Department'= 'Department';'FirstName'='GivenName';'LastName'='sn'; 'Department'='Department'; 'Manager'='Manager'} -Folder "" -WhatIf
  3. JSON with all properties{ "value": [ "IdName":"","Manager":"","SPS-Department":"","FirstName":"","Department":"" ]}
  4. Get Users from Azure AD: $users = Get-PnPAzureADUser
  5. 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
  6. 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

FreakIsTea avatar Oct 12 '23 09:10 FreakIsTea

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?

KoenZomers avatar Nov 08 '23 01:11 KoenZomers

Closing it due to lack of response, feel free to reopen this with more information, thanks !

gautamdsheth avatar Dec 29 '23 08:12 gautamdsheth