Forum Discussion

kevmcdonk's avatar
Nov 30, 2017

Intermittent 403 issue with Group provisioned Team Sites using New-PNPUnifiedGroup

I am seeing intermittent issues when using New-PNPUnifiedGroup to create a new group and SharePoint team site where the site itself only returns a 403 forbidden. Thanks to the post from Adam Wildash (https://techcommunity.microsoft.com/t5/SharePoint-Developer/403-for-modern-site-using-MS-code-snippet-for-provisioning/m-p/123013#M3712) I found that the LockState was set to NoAccess and setting it to Unlock works. However, this isn't something that I want to do without finding out why it's doing that. Has anyone seen similar issues?

 

 
Connect-PnPMicrosoftGraph -Scopes "Group.ReadWrite.All","User.Read.All"
    [string[]]$owners = "ADMINUSEREMAILREMOVED"
    $newGroup = New-PnPUnifiedGroup -DisplayName $ProjectDisplayName -MailNickname $ProjectName -Description $ProjectDisplayName -Owners $owners -Members $owners -IsPrivate

$groupUrl = $tenantSitesUrl + $ProjectName
        Write-Output "ApplyTemplate1 - Connecting to site $groupUrl"
        Connect-PnPOnline -Url $groupUrl -Credentials $mycreds

        Write-Output "ApplyTemplate1 - Get tenant site details"
        $Site=Get-PnPTenantSite -url $groupUrl -Detailed
        if ($Site.Status -eq "Creating") {
            Write-Output "ApplyTemplateERROR - Site still being created"
        }
        else {
           Write-Output "ApplyTemplate2 - Re-connect"
           Connect-PnPOnline -Url $groupUrl -Credentials $mycreds
           Write-Output "ApplyTemplate3 - Enable scripting on site for template to apply correctly"
            Set-PnPTenantSite -Url $groupUrl -NoScriptSite:$false
            Write-Output "ApplyTemplate3 - Apply template"
            Apply-PnPProvisioningTemplate -Path "ProjectSiteTemplate.xml"

            Write-Output "ApplyTemplate4 - Completed"
        }
        
        
        Write-Output "ApplyTemplate-6 - Apply project site template"
        Apply-PnPProvisioningTemplate -Path $template

        Write-Output "ApplyTemplate-7 - Applied template"
 
 
No RepliesBe the first to reply

Resources