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!


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"
  • Thanks but can you explain me with example?
    – user15099
    Feb 22 '13 at 21:00
  • Added examples from the articles. Feb 22 '13 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.