Tuesday, 25 June 2019

Set DenyAddAndCustomizePages to Disabled for modern Sharepoint sites via PowerShell PnP cmdlet


$usr = "userid@domain.com"
$pwd = "password"
$secpasswd = ConvertTo-SecureString $pwd -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ($usr, $secpasswd)

$adminUrl = "tenant admin url"
Connect-PnPOnline -url $adminUrl -Credentials $mycreds      // pass credentials
$pnpSite = Get-PnPTenantSite -Url $fullSiteUrl -Detailed
$pnpSite.DenyAddAndCustomizePages = "Disabled"
$pnpSite.Update()
$pnpSite.Context.ExecuteQuery()

We are setting Custom scripts disabled through above script. Hence we can add/upload custom css and scripts file to document library

No comments:

Post a Comment