Hi Folks,
Just came across a requirement of creating web application and site collections using power shell, posting it here.
Open an empty notepad file and copy paste below code segment :
Add-PsSnapin Microsoft.SharePoint.PowerShell
#My Parameters
$WebAppName = "MyWebApplication"
$WebAppHostHeader = "http://MyWebHost"
$WebAppPort = 7575
$WebAppAppPool = "AppPool_7575"
# This User has to be a Sharepoint Manager Account
$WebAppAppPoolAccount = "MyDomain\hirwani"
$WebAppDatabaseName = "WSS_Content_7575"
$WebAppDatabaseServer = "MySQLServer\SharePoint"
$template = Get-SPWebTemplate "STS#0"
# Create a new Sharepoint WebApplication
New-SPWebApplication -Name $WebAppName -Port $WebAppPort -HostHeader $WebAppHostHeader -URL ("http://" + $WebAppHostHeader) -ApplicationPool $WebAppAppPool -ApplicationPoolAccount ($WebAppAppPoolAccount) -DatabaseName $WebAppDatabaseName -DatabaseServer $WebAppDatabaseServer
# Create a new Sharepoint Site Collection
New-SPSite -Name "Root" -Url "http://in-mum-tfsport1:7575/" -Template $template -OwnerAlias "MyDomain\hirwani"
Save this notepad with .ps1 extension. Now execute it, you should get a new web application and site collection created.
Note : Change above parameters as per your requirement. Post here if you have any questions/suggestions.
Just came across a requirement of creating web application and site collections using power shell, posting it here.
Open an empty notepad file and copy paste below code segment :
Add-PsSnapin Microsoft.SharePoint.PowerShell
#My Parameters
$WebAppName = "MyWebApplication"
$WebAppHostHeader = "http://MyWebHost"
$WebAppPort = 7575
$WebAppAppPool = "AppPool_7575"
# This User has to be a Sharepoint Manager Account
$WebAppAppPoolAccount = "MyDomain\hirwani"
$WebAppDatabaseName = "WSS_Content_7575"
$WebAppDatabaseServer = "MySQLServer\SharePoint"
$template = Get-SPWebTemplate "STS#0"
# Create a new Sharepoint WebApplication
New-SPWebApplication -Name $WebAppName -Port $WebAppPort -HostHeader $WebAppHostHeader -URL ("http://" + $WebAppHostHeader) -ApplicationPool $WebAppAppPool -ApplicationPoolAccount ($WebAppAppPoolAccount) -DatabaseName $WebAppDatabaseName -DatabaseServer $WebAppDatabaseServer
# Create a new Sharepoint Site Collection
New-SPSite -Name "Root" -Url "http://in-mum-tfsport1:7575/" -Template $template -OwnerAlias "MyDomain\hirwani"
Save this notepad with .ps1 extension. Now execute it, you should get a new web application and site collection created.
Note : Change above parameters as per your requirement. Post here if you have any questions/suggestions.