1

We use Powershell and PNP to create sites and apply tenants. I've had pauses coded into the script to allow time for commands to complete in the past. Lately we've encountered the (403) Forbidden error much more frequently and even waiting overnight sometimes is not long enough before we can apply the PNPTemplate to the new site. I've also noticed this difference depending on authentication:

Blockquote

  1. Why are we consistently getting the 403 Forbidden error?
  2. Why does -weblogin result in a different error of There is no web named /testcommnew1/_vti_bin/Sites.asmx, even though the asmx page does exist as show below?

enter image description here

1 Answer 1

0

You site Url is not right in the PowerShell, the following PowerShell script for your reference.

#region Variables 
$Username = "user@tenant.onmicrosoft.com" 
$Password = "password" 
$siteURL = "https://tenant.sharepoint.com/sites/TestCommnew1" 

#endregion Variables

#region Credentials 
[SecureString]$SecurePass = ConvertTo-SecureString $Password -AsPlainText -Force 
[System.Management.Automation.PSCredential]$PSCredentials = New-Object System.Management.Automation.PSCredential($Username, $SecurePass) 
#endregion Credentials

Connect-PnPOnline -Url $siteURL -Credentials $PSCredentials

Apply-PnPProvisioningTemplate -Path "C:\powershell\Templates\TemplateCommunicationTopic20190725.xml"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.