Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Set-PnPSite command reporting (401) Unauthorized Error, in environment where legacy authentication is blocked #3043

Open
Hideo-doi opened this issue Jan 14, 2021 · 2 comments

Comments

@Hideo-doi
Copy link

Reporting an Issue or Missing Feature

■ Problem
After connecting to Sharepoint with Connect-PnPOnline, the following error occurs when executing Set-PnPSite

PS C: \ work> Connect-PnPOnline https://testtenant.sharepoint.com/sites/template_test -Credentials $ cred
PS C: \ work> Get-PnPSite

Url Compatibility Level


https://testtenant.sharepoint.com/sites/template_test 15

PS C: \ work>
PS C: \ work>
PS C: \ work> Get-PnPSite

Url Compatibility Level


https://testtenant.sharepoint.com/sites/template_test 15

PS C: \ work> Set-PnPSite -Sharing ExistingExternalUserSharingOnly
Set-PnPSite: The remote server returned an error: (401) Unauthorized. "Error.

  • Set-PnPSite -Sharing ExistingExternalUserSharingOnly
  • CategoryInfo: WriteError: (:) [Set-PnPSite], WebException
  • FullyQualifiedErrorId: EXCEPTION, PnP.PowerShell.Commands.Site.SetSite

■ Background

  • PnP Management Shell is registered as enterprise application

  • Blocking legacy authentication for SPO tenants
     ○SharePoint admin center> Policies> Access Control.
     ○ SPO Tenant Settings
      “LegacyAuthProtocolsEnabled”: False

  • Permissions are executed by global administrator and SPO administrator

■ Others

  • It has been confirmed that executing Set-PnPSite is possible if the tenant allows legacy authentication.

 → Does the Set-PnPSite command need to allow legacy authentication?

  • Get-PnPSite and Set-PnPWeb can be executed.

Expected behavior

  • The following commands can be executed

Set-PnPSite -Sharing ExistingExternalUserSharingOnly Set-PnPSite -NoScriptSite $ true Set-PnPSite -DisableSharingForNonOwners`

Actual behavior

Only Set-PnPSite gives an error that is not allowed

Steps to reproduce behavior

$ cred = credential
Connect-PnPOnline https://testtenant.sharepoint.com/sites/test -Credentials $ cred
Set-PnPSite -Sharing ExistingExternalUserSharingOnly

==============
Set-PnPSite: The remote server returned an error: (401) Unauthorized. "Error.

  • Set-PnPSite -Sharing ExistingExternalUserSharingOnly
  •   + CategoryInfo: WriteError: (:) [Set-PnPSite], WebException
      + FullyQualifiedErrorId: EXCEPTION, PnP.PowerShell.Commands.Site.SetSite
    
    
    
    

Which version of the PnP-PowerShell Cmdlets are you using?

-[] PnP PowerShell for SharePoint 2013
-[] PnP PowerShell for SharePoint 2016
-[] PnP PowerShell for SharePoint 2019
-[○] PnP PowerShell for SharePoint Online

What is the version of the Cmdlet module you are running?

Version: 3.25.2009.0

How did you install the PnP-PowerShell Cmdlets?

-[] MSI Installed downloaded from GitHub
-[○] Installed through the PowerShell Gallery with Install-Module
-[] Other means

@ghost
Copy link

ghost commented Jan 14, 2021

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 label Jan 14, 2021
@Hideo-doi
Copy link
Author

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

When do you triage about this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant