Set-PnPSite -DisableFlows and Set-PnPSite -DisableSharingForNonOwners throws Error 403
###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:###
- Are you using
Apply-SPOProvisioningTemplateorGet-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. - 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.
- 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?
- [ ] PnP PowerShell for SharePoint 2013
- [ ] PnP PowerShell for SharePoint 2016
- [X] PnP PowerShell for SharePoint Online
What is the version of the Cmdlet module you are running?
3.5.1901.0
How did you install the PnP-PowerShell Cmdlets?
- [X] MSI Installed downloaded from GitHub
- [ ] Installed through the PowerShell Gallery with Install-Module
- [ ] Other means

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"
I have the same issue. Any Updates on this?

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