Create Site Collection
function CreateSiteCollection
{
param(
[String]$siteUrl,
[String]$admin,
[String]$publishingTemplate,
[String]$siteName,
[String]$lcid
)
#Create SiteCollection if not exists
$siteExists = (Get-SPSite $SiteUrl -ErrorAction SilentlyContinue) -ne $null
if($siteExists)
{
Write-Host ''
Write-Host 'SiteCollection', $SiteUrl, 'already exists!' -foreground DarkRed
}
else
{
Write-Host ''
Write-Host 'Creating SiteCollection', $siteUrl, 'as Publishing Site ...'
New-SPSite -Url $siteUrl -OwnerAlias $admin -Name $siteName -Template $publishingTemplate -Language $lcid
Write-Host ''
$siteExists = (Get-SPSite $SiteUrl -ErrorAction SilentlyContinue) -ne $null
if($siteExists)
{
Write-Host 'SiteCollection was created successfully.'
}
else
{
Write-Host 'SiteCollection was not created.' -foreground DarkRed
}
}
}