Set Welcome page with PowerShell in SharePoint 2010
Introduction
It is very common that we want to set our custom page as a welcome page. Its always advisable instead of doing this from UI, provide script that can used in any environments.
In this post we will see the script how to set welcome page for a site using PowerShell
Set Welcome page
Remove-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
################################################### code###################################################
$sourceWeb = $null
try
{
$SiteUrl = "http://adigroup/myteamsite"
$sourceWeb = Get-SPSite -identity $SiteUrl
$oFolder = $sourceWeb.RootFolder;
$oFolder.WelcomePage = "Pages/MyCustomPage.aspx";
$oFolder.Update();
}
catch
{
write-host $_.exception
}
finally
{
if($sourceWeb -ne $null){$sourceWeb.Dispose()}
}
Conclusion
If you have to set welcome page in subsites, just get all the webs by $sourceWeb.AllWebs. Loop each web and use the same code as above.Hope you got how to implement the welcome page from PowerShell script.
June 22, 2012
В·
Adi В·
One Comment
Tags: Set Welcome Page in PowerShell В· Posted in: Powershell, Sharepoint 2010
One Response
Nice post. Here is one more post explains the same..
http://sureshpydi.blogspot.in/2014/03/change-default-homewelcome-page-in.html
Leave a Reply