cls
# Проверяем наличае аргументов в командной строке их должно быть два: URL родительского узла и имя нового узла
if($args[0] -eq $null){
    Write-Host "Error! Empty argument 'Url'! Use like this 'NewWeb.ps1 http://sps2010:101/NewWeb NewNodeName'"
    Write-Host " "
    Write-Host "Press any key ..."
    $null = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")    
    return
}
if($args[1] -eq $null){
    Write-Host "Error! Empty argument 'NewNodeName'! Use like this 'NewWeb.ps1 http://sps2010:101 NewNodeName'"
    Write-Host " "
    Write-Host "Press any key ..."
    $null = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")    
    return
}

Write-Host "Variables initialization ..."
$url = $args[0]
$newNodeName = $args[1]

$executingScriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent

# Грузим скриптлет SharePoint
Write-Host "SharePoint snapin loading ..."
if(!(Get-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction:SilentlyContinue))
{
    Add-PSSnapin Microsoft.SharePoint.Powershell
}
Write-Host "---------------------------------------------------------------"

# Place for Write-Progress block
Write-Host " "

$web = Get-SPWeb $url -ErrorAction:SilentlyContinue
if($web -ne $null)
{
    # Удаляем узел
    Write-Host "SharePoint web deleting ..."
    Remove-SPWeb –Identity $url –Confirm:$False
    Write-Host "---------------------------------------------------------------"
}

# Создаем узел
Write-Host "New SharePoint web creating ..."
Write-Host "---------------------------------------------------------------"
New-SPWeb -url $url -Template "STS#1" -Name $newNodeName -Description "Autocreated web"
Write-Host "---------------------------------------------------------------"

Write-Host "Operation complited."
#Write-Host "Press any key ..."
#$null = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")