Set Welcome page with PowerShell in SharePoint 2010

Set Welcome page with PowerShell in SharePoint 2010
3 votes, 4.67 avg. rating (92% score)

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:  В· Posted in: Powershell, Sharepoint 2010

One Response

  1. Suresh Pydi - April 28, 2014

    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

What is 4 + 14 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)