Question

Is there any way that I can create a web application, site collection and sites using poweshell and batch file automatically? So, User has to click on executable batch file which will create the web application on port 80 with content database written in powershell, site collection and 10 sub sites into it?

In my case the user doesn't know how to create a Sharepoint site. They just want to double click on file and the work is done!

Was it helpful?

Solution

You could use the following cmdlets to accomplish this:

New-SPWebApplication http://technet.microsoft.com/en-us/library/ff607931.aspx

New-SPSite http://technet.microsoft.com/en-us/library/ff607937.aspx

New-SPWeb http://technet.microsoft.com/en-us/library/ff607579.aspx

On each step, just assign to a variable so you can use it in the next cmdlet.

Using the examples from the articles, you could do:

$ap = New-SPAuthenticationProvider
$webApp = New-SPWebApplication -Name "Contoso Internet Site" -Port 80 -HostHeader sharepoint.contoso.com -URL "https://www.contoso.com" -ApplicationPool "ContosoAppPool" -ApplicationPoolAccount (Get-SPManagedAccount "DOMAIN\jdoe") –AuthenticationProvider $ap -SecureSocketsLayer
$site = New-SPSite http://www.contoso.com -OwnerAlias "DOMAIN\jdow" -HostHeaderWebApplication $webApp -Name "Contoso" -Template "STS#0"
New-SPWeb http://somesite/subweb1 -Template "STS#0"
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top