Hi @sns ,
For SharePoint Server:
- Step 1: Create a CSV file in the below format. Populate the column values according to your requirements.
- Step 2: Use this PowerShell script to read from CSV and create site collections in bulk. Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue # Function to Create new Site Collection Function Create-SPSite
{
param
(
[string]$Name = $(throw "Please Provide the Site Name!"),
[string]$URL = $(throw "Please Provide the Site URL!"),
[string]$Owner = $(throw "Please Provide the Site Owner!"),
[string]$Template = $(throw "Please Provide the Site Template!")
)
Try {
#Set the Error Action
$ErrorActionPreference = "Stop"
}#Check if the site collection exists already $SiteExists = Get-SPSite | where {$_.url -eq $URL} #Check if site exists in the recycle bin $SiteExistsInRecycleBin = Get-SPDeletedSite | where {$_.url -eq $URL} If($SiteExists -ne $null) { write-host "Site $($url) exists already!" -foregroundcolor red } elseIf($SiteExistsInRecycleBin -ne $null) { write-host "Site $($url) exists in the recycle bin!" -foregroundcolor red } else { #create site collection New-SPSite -Url $URL -Name $Name -OwnerAlias $Owner -Template $Template write-host "Site Collection $($url) Created Successfully!" -foregroundcolor Green }
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
Finally {
#Reset the Error Action to Default
$ErrorActionPreference = "Continue"
}
} # Read from CSV and create site collection Import-Csv "C:\SitesToCreate.csv" | Foreach-Object {
Create-SPSite -Name $.SiteName -URL $.SiteURL -Owner $.SiteOwner -Template $.SiteTemplate }
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.