Set welcome page

27/07/2012 18:11

#input parameters
$siteUrl="http://blogs/"
#$pageRelativePath = "Pages/ChamPages/RootBlogsWelcomePage.aspx"
$pageRelativePath = "Pages/default.aspx"

function SetWelcomePage
{
    param([string]$siteUrl, [string]$pageRelativePath)
    try
    {
        $site = Get-SPSite $siteUrl
        $web = $site.RootWeb
        $folder = $web.RootFolder
        $folder.WelcomePage=$pageRelativePath
        $folder.update()
        write-host "Page '" $pageRelativePath "' was set as welcome page for " $siteUrl
  
    }
    catch [Exception]
    {
        write-error $_
    }
    finally
    {
        $web.Dispose()
        $site.Dispose()
    }
  
}

SetWelcomePage -siteUrl $siteUrl -pageRelativePath $pageRelativePath