SharePoint 2010 PowerShell 系列 之 Create Site
# Check to ensure Microsoft.SharePoint.PowerShell is loaded $Snapin = get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'} if($Snapin -eq $null){ Write-host "Loading SharePoint Powershell Snapin" Add-PSSnapin "Microsoft.SharePoint.Powershell" } # Get WebApplication $WebAppName = "SharePoint - 999" $WebApp = Get-SPWebApplication $WebAppName if($WebApp -ne $null){ Write-host $WebApp.Url -foregroundcolor red $SiteUrl = $WebApp.Url+"sites/SharePoint" $SiteTitle = "Test SharePoint Powershell Create Site" $SiteTemplate = "STS#0" # STS#0 is team site # Check the site $targetUrl = Get-SPSite -identity $SiteUrl -regex if($targetUrl -ne $null){ Write-Host "the Site " $SiteTitle " is existing,deleting......" Remove-SPSite -Identity $SiteUrl -confirm } # create new site Write-Host "Creating new site " $SiteTitle " please waiting......" $NewSite = New-SPSite -Url $SiteUrl -OwnerAlias BTV\Administrator -Template $SiteTemplate -Name $SiteTitle Write-host "Finish Createed successful" -foregroundcolor green } else{ Write-host "WebApplication " +$WebAppName +" is not existing" }
SiteType 请参考