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 请参考

学习目录

 

posted @ 2012-06-30 21:58  @@@一统@@@  阅读(659)  评论(0编辑  收藏  举报