New Site Collection Through PowerShell

#Creates a SPSite in a new content database
Add-PSSnapin Microsoft.SharePoint.Powershell - ErrorAction SilentlyContinue;

$siteName = "IT";
$webAppUrl = "http://intranet2013.mydomain.com";
$template = "STS#0";

$ownerAlias = "mydomain\ggoyal";
$secondaryOwnerAlias = "mydomain\ggoyal";

$siteUrl = "$webAppUrl/sites/$siteName";
$databaseName = "SharePoint_Intranet_$siteName";
$databaseServer = "Test-Server";

New-SPContentDatabase -Name $databaseName -DatabaseServer $databaseServer -WebApplication $webAppUrl;

New-SPSite -Url $siteUrl -OwnerAlias $ownerAlias -SecondaryOwnerAlias $secondaryOwnerAlias -ContentDatabase $databaseName -Template $template -Name $siteName;

# New SPSite does not create the default groups

$web = Get-SPWeb $siteUrl;
$web.CreateDefaultAssociatedGroups("i:0#.w|$ownerAlias", "i:0#.w|$secondaryOwnerAlias", $siteName);
$web.update();

Comments

Popular Posts

SharePoint Interview Questions and Answers

Download Infopath Form Templates

How to get current logged user information using JavaScript ?

Steps to set Form based authentication (FBA) for SharePoint 2010

SharePoint Interview Questions and Answers II

Get List Items - JavaScript

Change Language for current user with JSOM in SharePoint Online

Cross Site List Rollup Web Part for SharePoint 2010

Hide Recently Modified Items

SharePoint 2010 CSS Chart