Skip to content

Instantly share code, notes, and snippets.

@hemache
Created May 8, 2016 11:27
Show Gist options
  • Save hemache/66e3c91de613d46ba44be4b412050d32 to your computer and use it in GitHub Desktop.
Save hemache/66e3c91de613d46ba44be4b412050d32 to your computer and use it in GitHub Desktop.
# variables
$siteUrl = "http://www.example.ma"
$defaultPageFileName = "Home.aspx"
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
$web = GetSPWeb -Identity $siteUrl
if([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web)) {
$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$publishingWeb.DefaultPage = ($publishingWeb.PagesList.Items | Where-Object { $_.File.Name -eq $defaultPageFileName }).File
$publishingWeb.Update()
} else {
Write-Error "this site doesn't use publishing site template"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment