Wednesday, June 24, 2015

Create SiteCollection Using Powershell

$homeUrl = read-host "Enter WebApplication URL"
$managepath = read-host "Enter site collection relative path here including any managed path. Managed path needs to be existing"
$scName = read-host "Enter site collection name here"
$sitesHomeUrl = $homeUrl + $managepath + "/" + $scName
$primaryOwner = read-host "Enter primary owner account here"
$secondaryOwner = read-host "Enter scondary owner account here"
$contentDatabaseName = read-host "Enter content database name here"
$contentDatabaseServerName = read-host "Enter database server name here"
$templateName = "BLANKINTERNETCONTAINER#0"

#Create new content database
New-SPContentDatabase -Name $contentDatabaseName -DatabaseServer $contentDatabaseServerName -WebApplication $homeUrl
#Create new site collection
write-host $sitesHomeUrl;
New-SPSite -Url $sitesHomeUrl -OwnerAlias $primaryOwner -SecondaryOwnerAlias $secondaryOwner -ContentDatabase $contentDatabaseName -Template $templateName

No comments:

Post a Comment