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 ( 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"
0 Replies