Set-PnPUserProfileProperty gives error: "This operation requires you to be managing your own data or have administrator privileges." #4904
Replies: 1 comment
-
As an alternative I also tried Sync-PnPSharePointUserProfilesFromAzureActiveDirectory method: Connect-PnPOnline -Url "https://companyxyz.sharepoint.com/sites/intranet" -ClientId "PnPPowerShellClientIDhere" $users = Get-PnPAzureADUser -Filter "companyName eq 'CompanyXYZ'" ...and this fails with: Sync-PnPSharePointUserProfilesFromAzureActiveDirectory: Failed to create sync job. Ensure you're providing users to sync and that the mapping is correct. So I tried it without "-Users $users" and that worked. I don't why it fails with the -Users switch since I can get the users with Get-PnPAzureADUser -Filter "companyName eq 'CompanyXYZ'" and I can save them to a "$users" variable normally. |
Beta Was this translation helpful? Give feedback.
-
This issue is also investigated here #277 (comment)
...but is closed last year so I'm not sure if anyone follows that anymore.
So I'm trying to read certain extension attributes from EntraID profiles and write the values into SharePoint User Profile custom properties.
Here's what I have tried:
#Connect to Microsoft Graph API
Connect-MgGraph -Scopes "User.Read"
#Fetch users where Company Name is "CompanyXYZ"
$users = Get-MgUser -Filter "companyName eq 'CompanyXYZ'"
#Connect to SharePoint Online
Connect-PnPOnline -Url "https://companyxyz-admin.sharepoint.com/" -ClientId
#Update SharePoint user profiles
foreach ($user in $users) {
$customAttribute = $user.companyName
Set-PnPUserProfileProperty -Account $user.UserPrincipalName -PropertyName "CompanyName" -Value $customAttribute
}
Set-PnPUserProfileProperty gives error: "This operation requires you to be managing your own data or have administrator privileges."
I have set these (Delegated) API permissions to PnP Powershell and I'm a Global Admin:
Microsoft Graph: User.Read.All
SharePoint: AllSites.FullControl, TermStore.ReadWrite.All, User.ReadWrite.All
Beta Was this translation helpful? Give feedback.
All reactions