I need to change my default page of my site :

$assignment = Start-SPAssignment

    $web.RootFolder.WelcomePage ="Pages/"+ $page
    Stop-SPAssignment $assignment

But the welcome page still the same. My site is publish site, is there another solution .

  • Try $web.RootFolder.WelcomePage = $page. Assuming $page is the url of the page (ie. default.aspx). Not sure if it will pick up pages from Pages library, but this definitely works for Site Pages. Oct 14, 2016 at 14:15
  • Yes it works fine for Teamsite , but not on publish site .
    – Imen Turki
    Oct 14, 2016 at 15:49

2 Answers 2


You said that you are working with a publishing enabled site. As far as I know, the code you are using can't work on Publishing sites, you should use the .DefaultPage property provided by the PublishingSite class instead.

Try something like this:

$publishingWeb = 

// note: pageFile is the acuall SPFile for the page, not just the url.
$publishingWeb.DefaultPage =$pageFile; 

Notice that you have to get a PublishingWeb first - think of it like a sort of wrapper that extends the normal SPWeb object and provides new functionalities specific for publishing enabled web sites.


The problem with this is that everytime you instantiate $web.RootFolder it grabs a new object form the DB so your call to .Update() is actually doing nothing.

Try the following code:

$folder = $web.RootFolder
$folder.WelcomePage = "Pages/" + $page

This should work.

  • Still the same !
    – Imen Turki
    Oct 14, 2016 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.