SharePoint 2010 PowerShell 系列 之 Create Web

学习目录

# 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){
    $SiteUrl = $WebApp.Url+"sites/sharepoint/PowerShell"
    $targetUrl = Get-SPWeb -Identity $SiteUrl -regex
    if($targetUrl -ne $null){
        Write-host "The web " $SiteUrl "is existing,deleting......"
        Remove-SPWeb -Identity $SiteUrl -confirm
        Write-Host "Deleting sucessful!" -foregroundcolor green
    }
    Write-Host "Creating new web "  $SiteUrl " please waiting......"
    New-SPWeb -Url $SiteUrl  -Template "STS#0" -Name "New Site"
    Write-Host "Created sucessful!" -foregroundcolor green
}
原文地址:https://www.cnblogs.com/Fengger/p/2571384.html