1

I am trying to iterate all the site collections and webs in a web application, create a blank page at the root, and set it to the home page. Setting the home page is no problem, but how to create a blank file at the root of each web, and set it to the home page? Below is my current effort.

$siteUrl = Read-Host "Enter Site URL"
$rootSite = New-Object Microsoft.SharePoint.SPSite($siteUrl)
$spWebApp = $rootSite.WebApplication

foreach($site in $spWebApp.Sites)
{

$webs= $site.AllWebs
try
{
    foreach ($web in $webs)
    {
        Write-Host $web.url


        $folder = $web.RootFolder
        $folder.WelcomePage = "test.aspx"
    }
}
catch
{
    write-host -f Red "error" $_.exception
    $errorlabel = $true
}
0

This might help you out. Allows you to create a new page in a page library. You can then set it as the welcome page.

https://stackoverflow.com/questions/18380019/how-to-create-a-page-in-a-given-sharepoint-2010-pages-library-using-powershell

  • how if it isn't a publishing site? – user3010406 Feb 10 '15 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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