PowerShell SharePoint site collection example

In this PowerShell SharePoint tutorial, we will discuss various PowerShell SharePoint site collection examples, like, how to create a site collection in SharePoint Online using PowerShell. Also, we will see how to create a subsite in SharePoint Online using PowerShell. We will discuss here:

  • What is a SharePoint site collection
  • What is a SharePoint site and subsite
  • How many site collections in SharePoint
  • Create site collection SharePoint Online using PowerShell
  • SharePoint PowerShell get all site collections and subsites
  • Get SharePoint Site Collection or Site Created Date using PowerShell
  • Create Subsite in SharePoint Online using PowerShell
  • Create multiple SharePoint sites using PowerShell
  • Create SharePoint Online Site Collection manually from SharePoint Online Admin center
  • Self-Service Site Collection in SharePoint
  • Fast Site Collection Creation in SharePoint 2016
  • SharePoint 2013 get site collection size PowerShell
  • How to delete corrupted SharePoint site collection using PowerShell

I will explain how to create a site collection using PowerShell in SharePoint Online Office 365. You can learn the process of provisioning Site Collection in SharePoint Online Office 365 using PowerShell.

To create a site collection in SharePoint, we need a site template id. For this, you can check my previous post on how to get all site templates in SharePoint Online using PowerShell. We are going to use site template id while creating the site collection in SharePoint Online using PowerShell.

As a developer, you should have the below things required to create a site collection or subsites using PowerShell in SharePoint Online.

  • Basic knowledge in PowerShell
  • SharePoint Online Admin center URL & Access
  • New Site Collection URL & Owner name
  • Site collection template ID

Table of Contents

What is SharePoint Site Collection

The SharePoint site collection concept is there in SharePoint on-premises versions like SharePoint 2013/2016/2019. A site collection consists of sites and subsite and it will have one top-level site.

We can create a site collection to host sites that will have common goals.

We can create two types of site collections in SharePoint.

  • Host-named site collections: Example: http://contoso.com/sites/teamA
  • Path-based site collections: Example: http://TeamA.contoso.com

What is SharePoint Site and Subsites

A SharePoint site is a place where people in your organization will work. It will have the contents in list or libraries, like information or documents.

We can create subsites under a site based on departments. These are known as the SharePoint subsites.

How many site collections in SharePoint

Let us see, how many site collections or sites in SharePoint Online and SharePoint On-premise environments.

Limit of site (Site collection) in SharePoint Online

  • In SharePoint Online, we can create 2million sites(site collection) per organization based on the Microsoft 365 plan.
  • The maximum storage for each site(site collection) is 25 TB.

Limit of Site Collection in SharePoint On-premise

  • In SharePoint On-premise, we can create the number of a site collection is 250,000 per farm. And the maximum number of site collections per farm is 500,000 personal sites plus 250,000 sites for all other site templates. All sites can reside in one web application or can be distributed across multiple web applications.
  • This limit will be affected by other factors, that might reduce the number of site collections that can be supported by a given content database (500 content databases per farm).
  • Care must be taken to avoid exceeding the supported limit when a container object, such as a content database contains a large number of other objects.
  • If a farm contains a smaller total number of the content databases, each of which contains a large number of a site collection and then farm performance affected long before the limit supported by the number of site collection reached.
  • Let’s discuss with an example if Farm A contains a web application that has 100 contents database, a supported configuration. If each of these content databases contains 1000 site collections.
  • The total number of site collections in the web application will be 100,000, which is falls within supported limits.
  • However, if the content database contains 10,000 site collections, then the number of site collections in the farm will be 1,000,000, which exceeds the limit for the number of site collections in web applications.
  • On the webserver, memory usage should be monitored, as memory usage depends on the usage pattern, and how many sites are accessed in the given time frame.
  • The supported limit for the number of websites in a site collection is 250,000.
  • The SharePoint collection can be as large as the content database size. The site collection per content database’s maximum size is 10,000 site collections.

List of Site Collection templates in SharePoint Online

Below is the list of site collection templates that are available in SharePoint Online. Suppose you want to create a SharePoint Online Modern Team site, then you have to use STS#3 template id. Similarly, if you want to create a classic team site, then you can use STS#0 template id.

Site Collection Template IDTemplate Name
STS#3Team site
STS#0Team site (classic experience)
BLOG#0Blog
BDR#0Document Center
DEV#0Developer Site
OFFILE#1Records Center
EHS#1Team Site – SharePoint Online configuration
BICenterSite#0Business Intelligence Center
SRCHCEN#0Enterprise Search Center
BLANKINTERNETCONTAINER#0Publishing Portal
ENTERWIKI#0Enterprise Wiki
PROJECTSITE#0Project Site
PRODUCTCATALOG#0Product Catalog
COMMUNITY#0Community Site
COMMUNITYPORTAL#0Community Portal
SRCHCENTERLITE#0Basic Search Center
visprus#0Visio Process Repository
SRCHCENTERLITE#0Basic Search Center
visprus#0Visio Process Repository

Create site collection SharePoint Online using PowerShell

Below is the PowerShell script to create a site collection in SharePoint Online Office 365. You can write, test, and debug the PowerShell script using Visual Studio Code or by using Windows PowerShell ISE.

function SPO-CreateNewSiteCollection {
#Parameters for Creating New Site Collection in SharePoint Online
param ($strNewSiteUrl, $strNewSiteTitle,$strNewSiteOwner,$strNewSiteQuota,$strNewSiteResourceQuota, $strNewSiteTemplateID, $strTenantAdminURL,$strTenantAdminName)

# Reading password in the PowerShell window
$password = Read-Host "Please enter the password for $($strTenantAdminName)" -AsSecureString
# Settingup the credentials
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $strTenantAdminName, $password
#Connecting to to SharePoint Online
try {
Connect-SPOService -Url $strTenantAdminURL -Credential $credentials
write-host "Report: Connected succesfully to SharePoint Online !!!" -foregroundcolor green
}
catch {
write-host "Error: Could not connect to SharePoint Online !!!" -foregroundcolor red
Break SPO-CreateNewSiteCollection
}
#verifying incase the site collection is already exists in SharePoint Online
$siteExists = get-SPOSite | where {$_.url -eq $strNewSiteUrl}
#verify if site collection exists even in the recycle bin
$siteExistsInRecycleBin = get-SPODeletedSite | where {$_.url -eq $strNewSiteUrl}
#Creating Site Collection by validting flag bits for above 2 scenarios
if (($siteExists -eq $null) -and ($siteExistsInRecycleBin -eq $null)) {
write-host "Report: Creating Site Collection $($strNewSiteTitle)" -foregroundcolor green
New-SPOSite -Url $strNewSiteUrl -title $strNewSiteTitle -Owner $strNewSiteOwner -StorageQuota $strNewSiteQuota -NoWait -ResourceQuota $strNewSiteResourceQuota -Template $strNewSiteTemplateID
}
elseif ($siteExists -eq $true) {
write-host "Report: $($strNewSiteUrl) already exists" -foregroundcolor red
}
else {
write-host "Report: $($strNewSiteUrl) still exists in the recyclebin" -foregroundcolor red
}
write-host "Report: Site Collection $($strNewSiteTitle) Created Successfully !!!" -foregroundcolor green
}
try {
# variables that are needed to host the new Site Collection
$strNewSiteUrl = Read-Host "Please enter URL for new Site Collection:: ex: https://onlysharepoint2013.sharepoint.com/sites/testSite"
$strNewSiteTitle = Read-Host "Name of New Site Collection:"
$strNewSiteOwner = Read-Host "Provide Admin account for new Site Collection:"
$strNewSiteQuota = 1000
$strNewSiteResourceQuota = 50
$strNewSiteTemplateID = Read-Host "Provide site Template-ID ex:STS#0"
$strTenantAdminURL = Read-Host "Provide Admin host URL: ex:https://<<tenant Name>>-admin.sharepoint.com/"
$strTenantAdminName = Read-Host "Provide Admin account ex:<<admin-user>>@<<tenant.onmicrosoft.com"

SPO-CreateNewSiteCollection -strNewSiteUrl $strNewSiteUrl -strNewSiteTitle $strNewSiteTitle -strNewSiteOwner $strNewSiteOwner -strNewSiteQuota $strNewSiteQuota -strNewSiteResourceQuota $strNewSiteResourceQuota -strNewSiteTemplateID $strNewSiteTemplateID -strTenantAdminURL $strTenantAdminURL -strTenantAdminName $strTenantAdminName
}
catch {
write-host "Error: $($strNewSiteUrl) still exists in the recyclebin" -foregroundcolor red
}

Output in PowerShell Window:

create sharepoint site powershell
create sharepoint site powershell

Our new Site Collection listed in Admin Center:

create site collection sharepoint online
create site collection sharepoint online

You can see below the newly created modern site collection in SharePoint Online.

create site collection sharepoint online powershell
create site collection sharepoint online powershell

This is how we can use PowerShell, to create a modern site collection in SharePoint Online Office 365.

Create Site Collection using PowerShell in SharePoint 2013/2016

As per Microsoft standards, we can create 750,000 site collections per SharePoint farm. In SharePoint we have various default templates to create Site Collection, these templates create the site collection and also create the default artifacts like some sample lists and libraries.

To know the list and its template code, execute the below command in PowerShell:

Get-SPWebTemplate

The output will look like as below:

create site collection using powershell
create site collection using powershell

Syntax for Site Collection Creation:

Get-SPWebTemplate
$template = Get-SPWebTemplate "STS#0"
New-SPSite -Url "" -OwnerAlias "<domain\user>" -Template $template

Example:

$template = Get-SPWebTemplate "STS#0"
New-SPSite -Url "http://:55245/" -OwnerAlias "DOMAIN\FARM ADMINISTRATOR" -Template $template

With this step, we have created Site Collection successfully using PowerShell in SharePoint 2013.

Create site collection SharePoint PowerShell

Below PowerShell command to create a site collection using PowerShell in SharePoint 2013/2016/2019.

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
New-SPSite http://sp2016:33779/ -OwnerAlias "MYSP\Administrator" -Name "My SP2016 Site Collection" -Template "BLANKINTERNET#0"
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
New-SPSite http://sp2016:33779/sites/MySP2016SiteCollection -OwnerAlias "MYSP\Administrator" -Name "My SP2016 Site Collection" -Template "STS#0"
create site collection sharepoint powershell
Create site collection SharePoint PowerShell

This is how we can create a site collection in SharePoint using PowerShell.

SharePoint powershell get all site collections and subsites

Now, we will see how to get all the sites and subsites under a web application using PowerShell in SharePoint 2013/2016. Here we will pass the SharePoint web application URL and it will give all the sites and subsites under it as well as the site URL, Title, and Created date.

Below is the PowerShell command to get all sites and subsites under the web application in SharePoint 2013/2016.

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
Get-SPSite -WebApplication http://win-pfcp2dgt8di/ -Limit All |
Select -ExpandProperty AllWebs | ft url, Title, Created -auto

The results will appear like below:

sharepoint powershell get all site collections and subsites
sharepoint powershell get all site collections and subsites

If you want to export the results into CSV then you can write like below:

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
Get-SPSite -WebApplication http://win-pfcp2dgt8di/ -Limit All |
Select -ExpandProperty AllWebs | ft url, Title, Created -auto > E:\AllSites.csv

This is how to get all site collections in web application PowerShell or get all sites and subsites SharePoint PowerShell.

Get SharePoint Site Collection or Site Created Date using PowerShell

Here, we will see how to get the SharePoint site collection or site created date using PowerShell in SharePoint 2013/2016. It is not possible to get the SharePoint site created date by using the browser. So it will be helpful to get SharePoint site creation information using PowerShell.

Also, we will see how to get all sites and subsites under a web application using PowerShell in SharePoint. And we will see, how to get SharePoint site collection or site created date using PowerShell.

Below is the PowerShell command to get the SharePoint site created date. It will display all the SharePoint site collection and site created date using PowerShell in SharePoint 2013/2016.

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
Get-SPSite -Limit All | %{$root = $_.rootweb; $date = $root.created.toShortDateString(); Write-Host "Site URL: $($root.url) Created Date: $($date)"}

It will display the results like below, it shows Site collection and all subsite created date using PowerShell in SharePoint 2013/2016.

Get SharePoint site collection created date PowerShell
Get SharePoint site collection created date PowerShell

This way we can get SharePoint site collection created date using PowerShell.

Create Subsite in SharePoint Online using PowerShell

Now, we will see how to create a subsite in SharePoint Online using PowerShell.

It is always a good idea to create subsites to organize user content for better collaboration across the organization thought it is SharePoint online.

The below PowerShell script will create a subsite in SharePoint online:

function new-spOnlineWeb {

#variables that needs to be set before starting the script
$siteURL = "<< SharePoint Site Collection URL >>"
$webURL = "MyFirstWeb"
$title = "My First Web"
$template = "STS#0"
$userName = "<< User-ID >>"
$useSamePermissionsAsParentSite = $true

# Let the user fill in their password in the PowerShell window
$password = Read-Host "Please enter the password for $($userName)" -AsSecureString

# set SharePoint Online credentials
$SPOCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $password)

#Creating client context object
$context = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)
$context.credentials = $SPOCredentials

#create web using WebCreationInformatin object (wci)
$wci = New-Object Microsoft.SharePoint.Client.WebCreationInformation
$wci.url = $webURL
$wci.title = $title
$wci.webtemplate = $template
$wci.useSamePermissionsAsParentSite = $useSamePermissionsAsParentSite
$createWeb = $context.web.webs.add($wci)
$context.load($createWeb)

#send the request containing all operations to the server
try{
$context.executeQuery()
write-host "info: Creating $($title)" -foregroundcolor green
}
catch{
write-host "info: $($_.Exception.Message)" -foregroundcolor red
}
}

new-spOnlineWeb

Below is the expected output:

create modern site collection sharepoint online powershell
create modern subsite collection sharepoint online powershell
powershell create sharepoint subsite

This is how to create a site collection in SharePoint Online using Office 365 using PowerShell. We also saw, how to create a subsite in SharePoint Online Office 365 using PowerShell.

Create Sub Site in Site Collection using PowerShell in SharePoint 2013/2016/2019

As per the Microsoft standards, we can create 250,000 subsites per SharePoint site collection and the syntax follows like this:

Syntax:

New-SPWeb -Template "STS#0"

Example:

Create a subsite using Powershell

New-SPWeb http://:55245/COSTCOInventory -Template "STS#0"

Update Subsite Title

$web = get-spweb("http://:55245/COSTCOInventory");
$web.TitleResource.SetValueForUICulture($web.UICulture, "COSTCO Inventory");
$web.update()

(or)

$web = get-spweb("http://:55245/COSTCOInventory");
$web.Title = "COSTCO Inventory";
$web.update()

This is how we can create a SharePoint subsite using PowerShell.

Create multiple SharePoint site using PowerShell

This part of the article is written by our EnjoySharePoint author, Anup Bhavsar.

Purpose of the article: The purpose of this SharePoint online article is to provide instruction on how to create SharePoint Online site collections in bulk using PowerShell.

The scope of the article: The scope of the article is to give detailed guidelines to understand and create SharePoint Online site collection.

Creating SharePoint Online Site Collection can be done using 2 methods:

  • PowerShell Script for bulk creation
  • Manual

Create SharePoint Online Site Collections in Bulk using PowerShell Script

We can create site collections in bulk in SharePoint online. Here we will see how we can create site collections from an excel file.

Creation of Site collection will be done through PowerShell Script using the below step:

Create a CSV file with the column name shown in below screenshot:

Bulk SharePoint online site collection creation powershell
Bulk SharePoint online site collection creation PowerShell

Sample CSV file: You can download the sample CSV file which I have used in this example.

The CSV file contains the information of the site collection which need to be created:

  • Site Collection URL: E.g. https://domainname.sharepoint.com/teams/SALES ‘domainname’ your domain name.
  • Owner: A user who is responsible for the site collection
  • Site collection Admin: The same user as owner or different user depending upon the requirement.
  • ResourceQuota: Using 300 resource quota default and the reason behind accepting the default is that if you are creating a site collection with team site template and if you are not going to use any sandbox custom solution. A custom solution requires high server resource quota. If the site collection is highly customized, then require high server resource quota.
  • StorageQuota: Put the number of gigabytes (GB). Minimum would be 1 GB and maximum would be 25600 GB (25 TB).
  • Template: Use Team site template ID STS#0.
  • Title: E.g. SALES with the above example.
  • TimeZoneId: Depending upon the requirement that means in which timezone the site collection should be stamped.

Open a Window PowerShell as administrator and run the Connect-SPOService cmdlet as shown below:

create a new site collection in sharepoint online using powershell
create a new site collection in SharePoint online using PowerShell

NOTE: Before running the above cmdlet, please make sure that the SharePoint Online management shell tool and it’s all modules are installed on the system. Also, check the execution policy is set as per the requirement.

Then supply the value and that value would be https://domainname-admin.sharepoint.com which is the URL of SPO admin center.

Then click enter, which will open a pop window to verify the credentials as shown below:

You can use Global administrator/SharePoint Administrator credentials to authenticate.

Then edit the below script and make sure to change the $AdminName and $csvfile = Import-csv “File Path”:

$AdminURL = "https://domainname-admin.sharepoint.com/"

$AdminName = ""

$csvfile = Import-csv ""

#User Names Password to connect

$SecurePWD = read-host -assecurestring "Enter Password for $AdminName"
$Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $AdminName, $SecurePWD
#Connect to SharePoint Online

Connect-SPOService -url $AdminURL -credential $Credential

#Add Site collection Admin

foreach($row in $csvfile)
{
Write-Host "Creating $($row."Site Collection URL")"
New-SPOSite -url $row."Site Collection URL" -Owner $row.owner -Template $row.Template -Title $row.Title -ResourceQuota $row.ResourceQuota -StorageQuota $row.StorageQuota -TimeZoneId $row.TimeZoneId
Set-SPOUser -site $row."Site Collection URL" -LoginName $row."Site Collection Admin" -IsSiteCollectionAdmin $True
}

NOTE:

  • $AdminName: This will be the same UPN that was used as Global administrator/SharePoint Administrator.
  • $csvfile = Import-csv “File path”: In this put the path of the CSV file that you have created in beginning.
  • Make sure to store CSV file and script in the same location.
  • If everything is properly executed, then you will see the New site collection is created and will appear in the URL list in the SharePoint Admin center under site collection section.

Create SharePoint Online Site Collection manually from SharePoint  Online Admin center

Log in to office 365 portal using Global Administrator or SharePoint Administrator credentials. If you have not tried Office 365, you can sign up for an Office 365 Enterprise E3 trial.

Select the app launcher icon in the upper-left and choose Admin to open the Office 365 admin center. In the left pane, select Resources, and then select Sites.

how to create a new sharepoint site in office 365
how to create a new SharePoint site in office 365

Select add a site.

create site collection sharepoint online powershell
create site collection SharePoint online PowerShell

If the admin doesn’t see the options above, then click on App launcher and then from Admin center tab click on SharePoint as shown below:

sharepoint powershell create site collection
SharePoint PowerShell create a site collection

It will take admin on the below landing page:

sharepoint online powershell create new site collection
SharePoint online PowerShell create a new site collection

Then click on the New tab and then Private Site Collection as shown in the above screenshot:

create site collection in sharepoint online using powershell
create site collection in SharePoint online using PowerShell

Once an admin clicks on Private Site Collection, a new window will pop up as shown below:

Admin must fill all the details as shown in above screenshot.

  • In the Title box, enter a name for the site collection.
  • In the Web Site Address, use ‘teams’ or ‘sites’ as a managed path, URL will be created.
  • In the Template Selection section, in the Select a language drop-down list, select a language for the site collection. Admin can enable the SharePoint multiple language interfaces on sites, but the primary language for the site collection will remain the one that has been selected here by admin.
  • NOTE: It’s important to select the appropriate language for the site collection because once it’s set, it cannot be changed. After creating a site collection, verify the locale and regional settings are accurate. (For example, a site created for Chinese will have its locale set to China.)
  • In the Template Selection section, under Select a template, choose the Team site template as per requirement.
  • In the Time Zone box, select as per the requirement.
  • In the Administrator box, type the username of your site collection administrator.
  • In the Storage Quota box, type the number of gigabytes (GB). The minimum would be 1 GB and the maximum would be 25600 GB (25 TB).
  • In the Server Resource Quota box, use 300 resource quota default and the reason behind accepting the default is that if you are creating a site collection with team site template and if you are not going to use any sandbox custom solution. The custom solution requires a high server resource quota. If the site collection is highly customized, then requires a high server resource quota.
  • Click on OK.

I hope this article helps you guys to create a site collection in SharePoint Online from the SharePoint Online admin center. Also, it will help to create SharePoint site collections in bulk using PowerShell in SharePoint Online.

Self-Service Site Collection in SharePoint 2019/2016/2013

SharePoint Self-Service Site Creation is a feature which is enabled by administrators and allows users to create their own top-level Web site. Microsoft has introduced the “Self-Service Site Collection” feature from SharePoint 2010 onwards.

I would like to discuss about few important aspects:

  • What is the “Self-Service Site Collection” feature in SharePoint?
  • How does “Self-Service Site Collection” helps the users in SharePoint?
  • How to enable “Self-Service Site Collection” feature in SharePoint 2013/2016?

SharePoint Self-Service Site Collection

In a SharePoint site, admin group members can create their own subsites, lists, libraries and also they can manage permissions as per the business needs.

Self-Service Site Creation is a feature which is enabled by administrators and allows users to create their own top-level Web site. User does not need administrator permissions on the web application server / virtual server, once this feature is enabled by FARM administrator any user part of the site can create the top level site collection.

Advantages of Self-Service Site Collection

As we all know SharePoint is meant for collaboration and document management with high security to data. In bigger business units sometimes the user has to create a separate high-level site to collaborate with all the other business units and clients.

It will be helpful to the user to create an individual top-level site without approaching an administrator.

How to enable “Self-Service Site Collection” feature in SharePoint 2013/2016?

Since this can have to be enabled in central administration, only FARM administrator can do this. Follow the below steps to enable this feature:

Log – on to the SharePoint application server with a FARM admin account. Open SharePoint Central Administration, (Start -> All Programs -> Administrative Tools -> SharePoint 2013 Central Administration).

Approach 1:

Activating feature from ribbon control

SharePoint Self-Service Site Creation
SharePoint Self-Service Site Creation
SharePoint 2013 Self-Service Site Creation
SharePoint 2013 Self-Service Site Creation

Approach 2:

Configuring from Application Management. From SharePoint 2013 central administration, click on Application Management, then click on Configure self-service site creation.

SharePoint 2016 Self-Service Site Creation
SharePoint 2016 Self-Service Site Creation
Self-Service Site Creation in SharePoint 2016
Self-Service Site Creation in SharePoint 2016

Once you configure / enable this feature any user from that site collection can create site collection using:

<<site collection URL>>_/layouts/15/scsignup.aspx
Ex: http://sharepoint13:12345_/layouts/15/scsignup.aspx

Creating site collection using non-admin user in SharePoint 2013/2016

Once it is configured, non admin users can create site collection in SharePoint 2013/2016.

enable self service site creation sharepoint 2013
enable self service site creation sharepoint 2013
enable self service site creation sharepoint 2016
enable self service site creation sharepoint 2016

You can see that it is not a sub site:

enable self service site creation sharepoint 2013
enable self service site creation sharepoint 2013

Now if we log on to central admin we can see this as site collection under http://sharepoint13:12345 web application.

how to enable self service site creation sharepoint 2016
how to enable self service site creation sharepoint 2016

Here, we saw, what is self service site creation in SharePoint 2013/2016? How we can enable self service site creation SharePoint 2013/2016.

Fast Site Collection Creation in SharePoint 2016

Now, let us see, the fast site collection creation in SharePoint 2016 using PowerShell. The fast site collection creation process improves site collection creation performance.

One of the new features of SharePoint 2016 is fast site collection creation feature.

Previously when you are trying to create SharePoint site collection it usually takes time to create a site collection. To reduce this performance issue, in SharePoint 2016 Microsoft provides the fast site collection feature which is supported now by PowerShell only.

You can create the fast site collection using PowerShell only because UI is not supported yet.

On a high level, this works at the SQL Server level which reduces round trips required between SharePoint and SQL Server. It simply copies at the SQL server level directly.

SharePoint 2016 provides few PowerShell commands to work with fast site creation.

Below are PowerShell cmdlets to work with Fast site Creation in SharePoint 2016.

Get-SPWebTemplatesEnabledForSiteMaster

This PowerShell command displays a list of template IDs that are enabled for SharePoint 2016 fast site creation.

PS E:\Users\Administrator> Add-PSSnapin Microsoft.SharePoint.PowerShell
Get-SPWebTemplatesEnabledForSiteMaster 
NameCompatibilityLevel
SPSPERS#215
SPSPERS#615
SPSPERS#715
SPSPERS#815
SPSPERS#915
SPSPERS#1015

When you run the above command, you can see the templated ids enabled for fast site creation.

Enable-SPWebTemplateForSiteMaster

By using this PowerShell command you can enable a template for fast site collection creation in SharePoint 2016.

Suppose you want to enable team site template id for fast site collection creation, then you can use the below PowerShell command.

STS#0 is the template id for the team site. You can check a very good article by Vlad in Absolute-SharePoint to see all the template ids.

Enable-SPWebTemplateForSiteMaster -Template "STS#0" -CompatibilityLevel 15

Once you run the above command you can see the team site template is now enabled for fast site creation.

PS E:\Users\Administrator> Add-PSSnapin Microsoft.SharePoint.PowerShell
Enable-SPWebTemplateForSiteMaster -Template "STS#0" -CompatibilityLevel 15
Get-SPWebTemplatesEnabledForSiteMaster
NameCompatibilityLevel
SPSPERS#215
SPSPERS#615
SPSPERS#715
SPSPERS#815
SPSPERS#915
SPSPERS#1015
STS#015

Get-SPSiteMaster

This command will display the site master information, it is something like this information will be used when we create a site collection using a fast site creation process.

Get-SPSiteMaster -ContentDatabase WSS_Content

By default it will provide information like below when you run the above command:

PS E:\Users\Administrator> Add-PSSnapin Microsoft.SharePoint.PowerShell
Get-SPSiteMaster -ContentDatabase WSS_Content

ContentDatabase          : SPContentDatabase Name=WSS_Content

SiteId                   : bb743227-37ac-404c-8ab3-e6e293313b38

TemplateName             : SPSPERS#10

Language                 : 1033

CompatibilityLevel       : 15

FeaturesToActivateOnCopy : {0ee1129f-a2f3-41a9-9e9c-c7ee619a8c33|00000000-0000-0000-0000-000000000000|;,

                           f661430e-c155-438e-a7c6-c68648f1b119|00000000-0000-0000-0000-000000000000|;,

                           e9c0ff81-d821-4771-8b4c-246aa7e5e9eb|00000000-0000-0000-0000-000000000000|;,

                           fa8379c9-791a-4fb0-812e-d0cfcac809c8|00000000-0000-0000-0000-000000000000|;…}

It looks like below:

sharepoint 2016 new feature fast site creation
sharepoint 2016 new feature fast site creation

New-SPSiteMaster

We can use this PowerShell command to new site master using any template. As for our requirement we will create a site master for the team site template.

New-SPSiteMaster -ContentDatabase WSS_Content -Template STS#0

This command will take some time to add to the site master. After this if you will run Get-SPSiteMaster PowerShell command you can see our team site template will be added to the site master like below:

PS E:\Users\Administrator> Add-PSSnapin Microsoft.SharePoint.PowerShell
Get-SPSiteMaster -ContentDatabase WSS_Content

ContentDatabase          : SPContentDatabase Name=WSS_Content

SiteId                   : ab6df6d4-6b48-4a54-97a8-4dac0f23443c

TemplateName             : STS#0

Language                 : 1033

CompatibilityLevel       : 15

FeaturesToActivateOnCopy : {4c42ab64-55af-4c7c-986a-ac216a6e0c0e|00000000-0000-0000-0000-000000000000|;,

                           8581a8a7-cf16-4770-ac54-260265ddb0b2|00000000-0000-0000-0000-000000000000|;,

                           3bae86a2-776d-499d-9db8-fa4cdc7884f8|00000000-0000-0000-0000-000000000000|;,

                           3cb475e7-4e87-45eb-a1f3-db96ad7cf313|00000000-0000-0000-0000-000000000000|;…}

ContentDatabase          : SPContentDatabase Name=WSS_Content

SiteId                   : bb743227-37ac-404c-8ab3-e6e293313b38

TemplateName             : SPSPERS#10

Language                 : 1033

CompatibilityLevel       : 15

FeaturesToActivateOnCopy : {0ee1129f-a2f3-41a9-9e9c-c7ee619a8c33|00000000-0000-0000-0000-000000000000|;,

                           f661430e-c155-438e-a7c6-c68648f1b119|00000000-0000-0000-0000-000000000000|;,

                           e9c0ff81-d821-4771-8b4c-246aa7e5e9eb|00000000-0000-0000-0000-000000000000|;,

                           fa8379c9-791a-4fb0-812e-d0cfcac809c8|00000000-0000-0000-0000-000000000000|;…}

create site collection using powershell
create site collection using PowerShell

New-SPSite

Now we can create a site collection from site master in SharePoint 2016 by using the PowerShell command below:

New-SPSite http://mypc/sites/MyFastSiteFromPowerShell -ContentDatabase "WSS_Content" -CompatibilityLevel 15 -CreateFromSiteMaster -Template "STS#0" -OwnerAlias"MySP\Administrator"

This will create the site collection in less time.

New-SPSite CreateFromSiteMaster PowerShell SharePoint 2016
New-SPSite CreateFromSiteMaster PowerShell SharePoint 2016

You can visit the site url to see the site collection created successfully.

Fast site creation feature sharepoint 2016
Fast site creation feature SharePoint 2016

Disable-SPWebTemplateForSiteMaster

Microsoft also provides below command to disable site template from site master.

Disable-SPWebTemplateForSiteMaster -Template STS#0

The above command will disable team site template from site master.

Remove-SPSiteMaster

This PowerShell command will remove site master from the content database.

Remove-SPSiteMaster -ContentDatabase "WSS_Content" -SiteId

SiteId: You can get the SiteId by running Get-SPSiteMaster -ContentDatabase WSS_Content command.

I hope this SharePoint tutorial helps to know about SharePoint 2016 Fast Site Collection Creation using PowerShell.

SharePoint check site collection size using PowerShell

Let us check out how to check SharePoint site collection size using PowerShell?

Below is the PowerShell command to check site collection size in SharePoint 2013/2016 using PowerShell. You can write, debug, and test PowerShell script using visual studio code or by using Windows PowerShell ISE.

$site = Get-SPSite http://win-pfcp2dgt8di/sites/EnjoySharePoint
$site.Usage.Storage/1000000
$site.Dispose();

Once you run the PowerShell command, you can see the output like below:

SharePoint 2013 Get SharePoint 2013 Site Collection Size using PowerShell
SharePoint 2013 Get SharePoint 2013 Site Collection Size using PowerShell

Get SharePoint 2013/2016 Site Collection using SharePoint Designer 2013

Now we can see how to get SharePoint 2013/2016 site collection using SharePoint designer 2013.

Just Open the SharePoint Site collection using SharePoint 2013 designer. In the home page, in the Site Information section, you will be able to see “Total Storage Used“. It will display your total size usage like below:

SharePoint 2013 Get SharePoint 2013 Site Collection Size using PowerShell
how to check site collection size SharePoint 2013

This is how to check site collection size SharePoint 2013 with PowerShell.

The web server at site collection URL does not appear to have Microsoft SharePoint Foundation installed

Let us see, how to fix error The web server at site collection URL does not appear to have Microsoft SharePoint Foundation installed which comes while trying to open a SharePoint 2013 site using SharePoint designer 2013.

Recently, while I was trying to open my SharePoint 2013 site using SharePoint 2013 designer, it gave an error as The Web server at “site collection URL” does not appear to have Microsoft SharePoint Foundation installed.

It looks like below:

The web server at site collection URL does not appear to have Microsoft SharePoint Foundation installed
The web server at site collection URL does not appear to have Microsoft SharePoint Foundation installed

The web server at site collection URL does not appear to have Microsoft SharePoint Foundation installed

We follow the below steps to solve the error “The Web server at site collection URL does not appear to have Microsoft SharePoint Foundation installed“.

Open your SharePoint 2013 central administration. Then click on “Security” from the left side. Then from the Security page, click on “Specify authentication providers” from the “General Security” section.

Then in the Authentication Providers page, select your web application for which you want to change from the right side.

Then click on “Default” link in “Zone” like below:

The web server at site collection URL does not appear to have Microsoft SharePoint Foundation installed error in SharePoint designer 2013
The web server at site collection URL does not appear to have Microsoft SharePoint Foundation installed

Then in the “Edit Authentication” page, go to the Client Integration section and click on Yes option in Enable Client Integration? like below, even if it is selected Yes. Just reselect once again and click on OK.

The web server at site collection URL does not appear to have Microsoft SharePoint Foundation installed
The web server at site collection URL does not appear to have Microsoft SharePoint Foundation installed

After this restart your SharePoint designer and it should work fine now.

This is how to fix error The web server at site collection URL does not appear to have Microsoft SharePoint Foundation installed which comes in SharePoint designer 2013.

Delete corrupted SharePoint site collection using PowerShell

Let us see, how to forcefully delete a corrupted site collection using PowerShell in SharePoint 2013/2016.

Recently we saw a few of our SharePoint site collections under a SharePoint web application as giving 404 pages not found the error. There are the site collections that we have created using code.

We saw on the central administration page, in view all site collections page we can see the sites are listed there, but when we click on a particular site collection it did not populate the URL, Title, Description Database Name, etc.

Everything was blank. So basically we can not do anything with the site collections only we can see those in the Site Collection List page. We thought to delete the site collections.

Then we try to delete the site collection using PowerShell by using Remove-SPSite command we got the below error:

<nativehr>0x80070003</nativehr><nativestack></nativestack>

Delete corrupted SharePoint site collection using PowerShell

Then we follow below PowerShell to delete the corrupted site collection:

You can put the PowerShell script in Windows PowerShell ISE and run the command.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$CorruptedSiteURL ="http://mynewwebapp:42885/sites/MyDeleteSiteCol"
$site = Get-SPSite $CorruptedSiteURL
$siteGUID = $site.Id
$siteDatabase = $site.ContentDatabase
$siteDatabase.ForceDeleteSite($siteGUID, $false, $false)

This time it deleted the SharePoint site collection successfully.

Here we learned how to delete corrupted site collection using PowerShell in SharePoint 2013/2016.

You may like the following SharePoint tutorials:

In this PowerShell SharePoint tutorial we learned:

  • SharePoint site collection vs site vs subsite
  • How many site collections in SharePoint
  • Create site collection SharePoint Online using PowerShell
  • Create SharePoint site collection using PowerShell (SharePoint 2013/2016/2019)
  • Create Subsite in SharePoint Online using PowerShell
  • Create multiple SharePoint sites using PowerShell
  • Create SharePoint Online Site Collection manually from SharePoint Online Admin center
  • Self-Service Site Collection in SharePoint
  • Fast Site Collection Creation in SharePoint 2016
  • How to check site collection size sharepoint 2013 with PowerShell
  • The web server at site collection URL does not appear to have Microsoft SharePoint Foundation installed
>