powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[BUG] Cannot set site owner since version 1.60

Open nerodrom opened this issue 5 years ago • 11 comments

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

nerodrom avatar Aug 02 '21 11:08 nerodrom

Have you tried version 1.7.0? It fixed another PnPTenantSite authorization issue that existed in 1.6.0.

ToddKlindt avatar Aug 02 '21 14:08 ToddKlindt

Yes, both - 1.60 and 1.70

nerodrom avatar Aug 02 '21 14:08 nerodrom

I think the command is solid. I was just able to use it like this and it worked. image Do you have another user or another tenant you can test with?

ToddKlindt avatar Aug 02 '21 15:08 ToddKlindt

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.

nerodrom avatar Aug 03 '21 05:08 nerodrom

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

edmund-davis avatar Aug 04 '21 15:08 edmund-davis

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 image 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

ollimenzel avatar Aug 05 '21 09:08 ollimenzel

Same error here. We are not able to set owners to sites via Set-PnPTenantSite. SharePointPnP modules are working image image

dbahnms avatar Aug 09 '21 05:08 dbahnms

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

ollimenzel avatar Aug 09 '21 06:08 ollimenzel

Hi @ollimenzel, your bug is similar to #968. #968 was fixed and fix is included in current nightly version. Could you try nightly version?

taisuke0710 avatar Aug 14 '21 05:08 taisuke0710

Hi I was able to use the command again thanks for this. Also it seems to work with the old PowerShell library too again

ollimenzel avatar Aug 16 '21 21:08 ollimenzel

Hello, apologies for this regression. Was able to fix it, will be available in tomorrow's nightly.

gautamdsheth avatar Sep 09 '21 13:09 gautamdsheth