Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.
This repository was 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

@Hideo-doi

Description

@Hideo-doi

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions