Skip to content

Instantly share code, notes, and snippets.

@thechriskent
Created November 11, 2019 21:02
Show Gist options
  • Save thechriskent/d5ae94dfac0cfb111842590476405c7d to your computer and use it in GitHub Desktop.
Save thechriskent/d5ae94dfac0cfb111842590476405c7d to your computer and use it in GitHub Desktop.
Demonstrates adding a domain to the list of allowed domains across multiple SharePoint sites (useful for the Embed webpart)
$SiteUrls = @("HR","Accounting","IT")
foreach($SiteUrl in $SiteUrls) {
Write-Host -ForegroundColor Cyan "Applying to $SiteUrl..."
$FullSiteUrl = "https://superspecial.sharepoint.com/sites/$SiteUrl"
Connect-PnPOnline $FullSiteUrl -ErrorAction Stop
$site = Get-PnPSite -Includes CustomScriptSafeDomains
$ctx = Get-PnPContext
$ssDomain = [Microsoft.SharePoint.Client.ScriptSafeDomainEntityData]::new()
$ssDomain.DomainName = "special.hosted.panopto.com"
$site.CustomScriptSafeDomains.Create($ssDomain)
$ctx.ExecuteQuery()
Disconnect-PnPOnline
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment