Permission issue with Invoke-PnPQuery
-
18-02-2021 - |
Вопрос
I am trying to run the code below to update the "noCrawl" property but I am facing an issue with Invoke-PnPQuery:
Connect-PnPOnline -Url $url -Credentials $cred
$Web = Get-PnPWeb
$Web.NoCrawl = $true
$Web.Update()
Invoke-PnPQuery
I get the following error
Invoke-PnPQuery : Access denied. You do not have permission to perform this action or access this resource. Au caractère Ligne:2 : 13 Invoke-PnPQuery CategoryInfo : NotSpecified: (:) [Invoke-PnPQuery], ServerUnauthorizedAccessException FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerUnauthorizedAccessException,PnP.PowerShell.Commands.Base.InvokeQuery
Seems like a permissions issue, but i'm struggling with it.
Can someone help please?
Решение
I finally figure it out.
To perform an action like to upadate "nocrawl" property, you need to have another property of the web "-DenyAndAddCustomizePages" switched to false:
Connect-PnPOnline -Url $adminURL -Credentials $cred
Set-PnPSite -Identity $url -DenyAndAddCustomizePages $false
Then the code can be executed without any problem