Create Site Collections And Sites In SharePoint Using PowerShell - Part One

Introduction

  1. Document Objective

    The purpose of this document is to provide instructions on using this PowerShell script to create site collections and sites in sharepoint using different web templates.

  2. Audience

    This document is targeted to developers and architects responsible for creating site collections and sites using multiple combinations with different web templates. Please note that root site collection must be present with web application URL. The code can be modified and extended as per requirements.

Creating Site Collection and then sub site within same site collection

Procedure
  1. Go to Start > Open SharePoint 2013 Management Shell.

  2. Run as administrator.

    administrator

  3. Run the script.

    script
  4. Enter Web application url. Press Enter.

    cmd

  5. It will validate the web application url. If root site collection is present at web application url, it will ask if user wants to create site collection or sub site.

    cmd

  6. Enter 1. It will ask the site collection details. Enter Site Title, Site description and Site Url (must be a valid URL) URL is prepopulated in ‘e.g’ part. User can use this URL.

    cmd

  7. After entering all details, it will ask for web template category choice.

    Enter 1. Then, it will ask for web template for this particular web template category.
    Enter 1 for Team Site.

    cmd

  8. Enter Primary administrator and Secondary Administrator(optional) details.Press Enter.

    cmd

  9. Site Provisioning process will take place.

    cmd

  10. After Site Collection gets provisioned, it will ask if user wants sub site to be created under newly created site collection.

    cmd

  11. Enter “y”. It will ask for Sub Site details. Enter these details.

    cmd

  12. Site Provisioning process will take place.

    cmd

  13. After successfully provisioning the site, it will ask if another sub site to be created under same site collection.

    cmd

  14. Enter “y” if user wants another sub site to be created under same site collection. Otherwise enter “n”.

    cmd

  15. Then it will ask if another site collection under same web application to be created. Enter “y” if user wants another site collection to be created under same web application. Otherwise enter “n”.

    cmd

  16. Then it will ask if another Site collection or sub site to be created. Enter “y”.

    cmd

  17. User can follow steps 5 to 13 to create multiple site collections and sub sites with different web templates.