Monday, June 18, 2012

SharePoint 2010 - Creating a Web Application By PowerShell

I found a blog, there are scripts for creating Farm, Web Application, Site Collection: http://blog.brianbeach.com (all credits to Brian). I want to write it here, like a reminder for myself. In addition, I think that the sharing knowledge is a best way to help to each other.

$WebAppURL = "http://intranet.DOMAIN.com"
$HostHeader = "intranet.DOMAIN.com"
$ContentDatabase = "Content_Intranet_Default"
$WebAppName = "Intranet Web Application"
$AppPoolName = "Intranet Content"
$AppPoolUserName = "DOMAIN\SERVICE_ACCOUNT"

Write-Host "Creating the intranet web application"
$AppPoolCred = Get-Credential $AppPoolUserName
$AppPoolAccount = New-SPManagedAccount -Credential $AppPoolCred
$AuthProvider = New-SPAuthenticationProvider
$WebApp = New-SPWebApplication -ApplicationPool $AppPoolName -ApplicationPoolAccount $AppPoolAccount -Name $WebAppName -URL $WebAppURL -HostHeader $HostHeader -Port 80 -AuthenticationProvider $AuthProvider -DatabaseName $ContentDatabase


$SiteName = "Intranet Root Site"
$OwnerEmail = "USER_NAME@DOMAIN.com"
$OwnerAlias = "DOMAIN\USER_NAME"
$SiteURL = "http://intranet.DOMAIN.com"
$SiteTemplate = "STS#1"

Write-Host "Creating a default site collection in the intranet web application"
New-SPSite -Url $SiteURL -owneralias $OwnerAlias -ownerEmail $OwnerEmail -Template $SiteTemplate
$Web = Get-SPWeb $SiteURL
$Web.title = $SiteName
$Web.update()

No comments:

Post a Comment