pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
988 stars 662 forks source link

Set-PnPSite -DisableFlows and Set-PnPSite -DisableSharingForNonOwners throws Error 403 #1863

Open Carlos-35 opened 5 years ago

Carlos-35 commented 5 years ago

Notice: many issues / bugs reported are actually related to the PnP Core Library which is used behind the scenes. Consider carefully where to report an issue:

  1. Are you using Apply-SPOProvisioningTemplate or Get-SPOProvisioningTemplate? The issue is most likely related to the Provisioning Engine. The Provisioning engine is not located in the PowerShell repo. Please report the issue here: https://github.com/officedev/PnP-Sites-Core/issues.
  2. Is the issue related to the cmdlet itself, its parameters, the syntax, or do you suspect it is the code of the cmdlet that is causing the issue? Then please continue reporting the issue in this repo.
  3. If you think that the functionality might be related to the underlying libraries that the cmdlet is calling (We realize that that might be difficult to determine), please first double check the code of the cmdlet, which can be found here: https://github.com/OfficeDev/PnP-PowerShell/tree/master/Commands. If related to the cmdlet, continue reporting the issue here, otherwise report the issue at https://github.com/officedev/PnP-Sites-Core/issues

Reporting an Issue or Missing Feature

Issue

Expected behavior

I want to disable Flow and Sharing for non owners. So I use Set-PNPSite with the Parameters -DisableSharingForNonOwners and -DisableFlows.

Actual behavior

Both commands throw the same error: The remote server returned an error (403) forbidden

Steps to reproduce behavior

Set-PnPSite -DisableFlows
Set-PnPSite -DisableSharingForNonOwners

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

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

3.5.1901.0

How did you install the PnP-PowerShell Cmdlets?

error 2 error 1

fbn10040 commented 5 years ago

Hello. Any update on this? I am also getting the error:

Set-PnPSite : The remote server returned an error: (403) Forbidden

Currently I am running this version "SharePointPnPPowerShellOnline\3.9.1905.3"

bernd-spieth commented 5 years ago

I have the same issue. Any Updates on this?

alisalih1 commented 5 years ago

Error with Set-PnPSite

I have the same issue but I think I found the behavior. I used -UseWeblogin and I got the 403 Access denied. But when I used the regular connect-pnponline, it worked without error.

igloo785 commented 5 years ago

I was able to use "Set-PnPSite -DisableFlows" when I used an account with SharePoint Administrator role or an account with site collection administrator access on the SharePoint Admin site.

In the Set-PnPSite code it accesses the majority of the site's properties by using the SharePoint Admin site context.

martinlingstuyl commented 4 years ago

Hi guys,

I got a 401 error everytime I used the Set-PnPSite command. When viewing the request through fiddler I noticed that the rest request was posted to the tenant admin sitecollection.

So using the following code, I am now able to use Set-PnpSite:

Connect-PnPOnline -Url "https://tenant-admin.sharepoint.com" -AppId $appId -AppSecret $appSecret 
Set-PnPSite -Identity "https://tenant.sharepoint.com/sites/site1" -DisableSharingForNonOwners

Hope this helps for you as well!

One would say this would belong in Set-PnPTenantSite.

Using version 3.15.19 of PnP Powershell.

bernd-spieth commented 4 years ago

I found no solution for the 403 error so I use a direct CSOM call to disable flow:

Write-Message -MessageType Activity -Message ("Disabling Flow in site '{0}'" -f $siteUrl)
$ctx = Get-PnPContext
$ctx.Site.DisableFlows = $true
$ctx.ExecuteQuery()

I haven't tried the PNP cmdlet parameter in the last couple of month maybe the error is fixed in the meantime. But if not you can use the code above to configure the site.

mariolonghi commented 4 years ago

This still an issue on version 3.21.2005.1 I can do it via the CSOM as reported above (@Bernd-Spieth ) but it would be good to get that solved