[BUG] Cannot set site owner since version 1.60
Reporting an Issue or Missing Feature
Cannot add new site owners to existing sites as global admin via command Set-PnPTenantSite
Expected behavior
Set-PnPTenantSite should add new site owners even if you are not a current owner of this site.
Actual behavior
Set-PnPTenantSite : The remote server returned an error: (401) Unauthorized. At line:1 char:1
- Set-PnPTenantSite -Url "https://****.sharepoint.com/sites/SetOwner ...
-
+ CategoryInfo : WriteError: (:) [Set-PnPTenantSite], WebException + FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.SetTenantSite
What is the version of the Cmdlet module you are running?
This issue persists since version 1.6.0.
Which operating system/environment are you running PnP PowerShell on?
- [x] Windows
- [ ] Linux
- [ ] MacOS
- [ ] Azure Cloud Shell
- [ ] Azure Functions
- [ ] Other : please specify
Have you tried version 1.7.0? It fixed another PnPTenantSite authorization issue that existed in 1.6.0.
Yes, both - 1.60 and 1.70
I think the command is solid. I was just able to use it like this and it worked.
Do you have another user or another tenant you can test with?
Hi Todd, have you tried to add an new site owner, too? Be sure that the user who is running the command, is not a site owner. My service account is a SharePoint admin, global admin should work, too.
I'm seeing similar behaviour on 2 tenants with 1.7.9 (preview) installed. Could this be related to issues which were recently addressed relating to Get-PnPTenantSite? https://github.com/pnp/powershell/issues/927
I'm having the same Problem trying to update the sharing permissions for SiteCollections.
I'm running my Script under SharePoint App-only principal with tenant permissions
The script was running for month now, but stopped working 2-5 days ago. With 401 error.
I even tried to create a new App permission, but it's giving me the same error
Same error here. We are not able to set owners to sites via Set-PnPTenantSite.
SharePointPnP modules are working

I was able to pin-point the problem even further for me. This call is working fine: Set-PnPTenantSite -Identity https://$($tenantName).sharepoint.com/sites/$($EMail) -SharingAllowedDomainList "xxx.com,YYY.com" -SharingDomainRestrictionMode AllowList but if I include -SharingCapability ExistingExternalUserSharingOnly as needed, I get a 401 message. Seems to be really strange, that just one parameter isn't working, as of last week
Hi @ollimenzel, your bug is similar to #968. #968 was fixed and fix is included in current nightly version. Could you try nightly version?
Hi I was able to use the command again thanks for this. Also it seems to work with the old PowerShell library too again
Hello, apologies for this regression. Was able to fix it, will be available in tomorrow's nightly.