Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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!

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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"
share|improve this answer
    
Thanks but can you explain me with example? –  user15099 Feb 22 '13 at 21:00
    
Added examples from the articles. –  John Chapman Feb 22 '13 at 21:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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