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.

image

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 Smile. If you remember back in STSADM (MOSS), we did not have that luxury! Below we are creating a web application called SharePointStack.

image

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.

image

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.

image

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.

image

I chose the Blank Site template.

image

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.

image

You can use Get-Help New-SPSite command to get more information about the command parameters.

image

Well that’s about it Smile