Powershell管理SharePoint站点1
1. 打开SharePoint站点里面的treeview
$spWeb = Get-SPWeb -Identity http://siteurl
$spWeb.TreeViewEnabled = $true
$spWeb.Update()
$spWeb.Dispose()
2. 管理站点Quick Launch
$spWeb = Get-SPWeb -Identity http://siteurl
$spWeb.QuickLaunchEnabled = $true
$spWeb.Update()
$spWeb.Dispose()
3. 添加Top link
$spWeb = Get-SPWeb -Identity "http://siteurl";
$node = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode $nodeTitle,$NodeUrl, $true;
if ($addAsFirst) {
$spWeb.Navigation.TopNavigationBar.AddAsFirst($node);
} else {
$spWeb.Navigation.TopNavigationBar.AddAsLast($node);
}
$spWeb.Dispose();
4. 取得当前站点的theme
$spWeb = Get-SPWeb -Identity http://nimaintra.net
$theme = [Microsoft.SharePoint.Utilities.ThmxTheme]::GetThemeUrlForWeb($spWeb)
写成方法:
function Get-SPTheme([string]$url) {
$spWeb = Get-SPWeb -Identity $url
$theme = [Microsoft.SharePoint.Utilities.ThmxTheme]::GetThemeUrlForWeb($spWeb)
if (-not([string]::IsNullOrEmpty($theme)))
{
[Microsoft.SharePoint.Utilities.ThmxTheme]::Open($spWeb.Site, $theme) |
Format-List -Property @{Name="Theme";Expression={$_.Name}
},
@{Name="Type";Expression={$_.ThemeType}},
@{Name="RelativeUrl";Expression={$_.ServerRelativeUrl}},
@{Name="Description";Expression={$_.AccessibleDescription}}
}
else {
Write-Host "Default theme"
}
$spWeb.Dispose()
}
调用:Get-SPTheme -url http://siteurl
5. 设置站点Logo,标题和描述
$spWeb = Get-SPWeb -Identity http://siteurl
$spWeb.SiteLogoUrl = "http://siteurl/Pictures/logo.bmp"
$spWeb.SiteLogoDescription = "My Description"
$spWeb.Update()
$spWeb.Dispose()
$spWeb = Get-SPWeb -Identity http://siteurl
$spWeb.Title = "New Title"
$spWeb.Description = "New Description"
$spWeb.Update()
$spWeb.Dispose()