使用PowerShell 创建标准站点,可以定制其站点模板、站点配额、语言、管理员、Site Collections Group、站点名、站点简介等。。
function New-SiteCollection
{
param ( $url, $name, $language, $description, $sitetemplate, $quotatemplate, $listitem )
$databasename = "WSS_Content_" + ($url -split "sites/")[-1].ToUpper()
#$databasename = "WSS_Content_" + ($url -split "sites/")[-1]
$item[‘Task Status‘] = ‘Creating DataBase ...‘
$item.Update()
New-SPContentDatabase -Name $databasename -WebApplication https://sp-alg.asmpt.com/ -DatabaseServer "algnts135.algex.asmpt.com" -WarningSiteCount 0 -MaxSiteCount 1
New-SPSite -Url $url -ContentDatabase $databasename -Language $language -Name $name -OwnerAlias "algex\spsadmin" -SecondaryOwnerAlias "algex\80024628" -Template $sitetemplate -Description $description -QuotaTemplate $quotatemplate
$item[‘Task Status‘] = ‘Creating SiteCollection ...‘
$item.Update()
$web = Get-SPWeb $url
Create-Group -web $web
$web.MembersCanShare=$false
$web.RequestAccessEmail=‘‘
$web.Update()
$user = $web.EnsureUser("algex\alg sharepoint admin")
Set-SPUser -Identity $user -Web $web -IsSiteCollectionAdmin
$web.Dispose()
}
function New-SubSite
{
param ( $url, $name, $language, $template, $description, $secondowner )
$web = New-SPWeb $url -Template $template -Name $name -Description $description -Language $language -UseParentTopNav -AddToQuickLaunch -AddToTopNav -UniquePermissions
# $web = Get-SPWeb $url
Create-Group -web $web
$web.MembersCanShare=$false
$web.RequestAccessEmail=‘‘
$web.Update()
$user = $web.EnsureUser("algex\alg sharepoint admin")
Set-SPUser -Identity $user -Web $web -IsSiteCollectionAdmin
$web.Dispose()
}
function Create-Group
{
param ( $web )
foreach($n in "Visitors", "Editors", "Contributers", "Owners")
{
if($n -eq "Visitors")
{
$PMlevel = "Read"
}
elseif($n -eq "Editors")
{
$PMlevel = "Edit"
}
elseif($n -eq "Contributers")
{
$PMlevel = "Contribute"
}
else
{
$PMlevel = "Design"
}
$GroupName = $web.Title + " " + $n
$Web.SiteGroups.Add($GroupName, $web.Site.Owner, $web.Site.Owner, $GroupDescription)
$Group = $web.SiteGroups[$groupName]
$roleAssignment = new-object Microsoft.SharePoint.SPRoleAssignment($group)
$roleDefinition = $web.Site.RootWeb.RoleDefinitions[$PMlevel]
$roleAssignment.RoleDefinitionBindings.Add($roleDefinition)
$web.RoleAssignments.Add($roleAssignment)
$web.Update()
$web.Dispose()
}
}