Using SharePoint 2010 Management Shell to Create Web Applications and Site Collections
Power Shell is one outstanding tool for managing and configuring SharePoint 2010 without using the web GUI. A good use of Power Shell is creating CMDLets to automate the process of provisioning sites and site collections. In today’s walkthrough we will create a new web application and a site collection using Power Shell without accessing SharePoint 2010 Central Administration site.
So let’s start by launching SharePoint 2010 Management Shell under Start –> All Programs –> SharePoint 2010 Products. Make sure to run the Management Shell as an Administrator.
To create a new web application we use the New-SPWebApplication command. The best thing about Power Shell commands is that you don’t need to specify the parameters when calling the command, it will ask you for each parameter . If you remember back in STSADM (MOSS), we did not have that luxury! Below we are creating a web application called SharePointStack.
As you can see from the screenshot above, I used the following parameters:
- Name: Application (Website) name in IIS
- ApplicationPool: Application pool used for the application
- ApplicationPoolAccount: Identity which the application pool will run under
- Url: Url of the web application
- Port
You can use Get-Help New-SPWebApplication command to get more information about the command parameters.
Now let’s go and create the site collection using the New-SPSite command. This time I am not going to specify the parameters. The command will ask me for the parameters.
As you can see from the screenshot above, I used the following parameters:
- Url: Url used to access the site collection
- OwnerAlias: Site collection administrator user account
If you don’t specify the Template parameter, the user will have the chance to set the site template on the first request.
I chose the Blank Site template.
If you want to set the template when creating the site, you can add the Template parameter. To get a list of the templates installed, you can use the Get-SPWebTemplate command. For example, the Blank Site template parameter is: STS#1.
You can use Get-Help New-SPSite command to get more information about the command parameters.
Well that’s about it
Comments
- Anonymous
March 28, 2012
+1 - Anonymous
March 28, 2012
Thanks :-) +1 for you too loool