Вопрос

Ok this site recently got switched form a modern site to a classic site and now I cannot use anything on the site to include turning on and off features with powershell. This is a sharepoint online site with office 365 permissions. I used to be able to use powershell on this site but now i am only getting a 403 error. Any help would be greatly appreciated.

Note: This error was specific to a single site collection. I was able to run all pnp commands on other site collections.

Connect-PnPOnline

I enter the URl and credentials without fail, but the minute I run

Get-PnPProvisioningTemplate -Out "example-Template.xml"

or

Set-PnPList -Identity "Some Library" -ForceCheckout $false

I will get the following error

  Set-PnPList : The remote server returned an error: (403) Forbidden.
At line:1 char:1
+ Set-PnPList -Identity "Some Library" -ForceCheckout $false
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Set-PnPList], WebException
    + FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Lists.SetList

I ran the log against it also and got this error in line one

 powershell.exe Error: 0 : 2020-09-16 08:03:52.1674 [OfficeDevPnP.Core] [0] [Error] ExecuteQuery threw following exception: System.Net.WebException: The remote server returned an error: (403) Forbidden.
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
Это было полезно?

Решение

I went through multiple steps to solve this issue.

First I checked permissions to see if I was having an error with the group permissions.

  • I removed my permissions from the group then re added them (No change)
  • I added myself with full control outside of the group (no change)
  • I removed older versions of the managment counsel and pnp and made sure mine was updated to the most current version. (No change)

Fix:

The thing that fixed it was changing the -Lockstate

Set-PnPTenantSite -Url https://target.sharepoint.com/sites/traget-site -LockState Unlock
Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top