Sunday, May 8, 2016

Change SharePoint App Master Page

Problem
Accessing referenced file  is not allowed because the reference is outside of the App Web.

Solution

The below script is used to change the app web master page

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

$siteCollection = Get-SPSite "site collection url"
$allWebs = $siteCollection.AllWebs;

$allWebs | foreach-object {
if($_.IsAppWeb -eq $true){
if($_.Url -eq "app url")
{
$_.CustomMasterUrl = $_.ServerRelativeUrl+"/_catalogs/masterpage/app.master"
$_.MasterUrl = $_.ServerRelativeUrl+"/_catalogs/masterpage/app.master"
$_.Update()
write-host "App at "+$_.ServerRelativeUrl+"updated!"
}
}

}

No comments:

Post a Comment