вторник, 19 июня 2012 г.

Назначение домашней страницы для SharePoint-сайта через PowerShell


cls


if(!(Get-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction:SilentlyContinue))
{
    Add-PSSnapin Microsoft.SharePoint.Powershell
}


# -------------------------------------------------
# Сайт
$site="http://sp-serv"
# Страртовая страница
$homePage="home.aspx"
# -------------------------------------------------


$assignment=Start-SPAssignment
$web=Get-SPWeb -Identity $site -AssignmentCollection $assignment


# Назначение домашней страницы
$rootFolder=$web.RootFolder
$rootFolder.WelcomePage=$homePage
$rootFolder.Update()


Stop-SPAssignment $assignment
$web.Update()
$web.Dispose()


write-host 'Для сайта ' -nonewline 
write-host $site -nonewline -foregroundcolor Blue
write-host ' домашняя страница изменена на ' -nonewline
write-host $homePage -foregroundcolor Blue