Create multiple SharePoint site collections with different owners

Scenario description

PowerShell allows you to create site collections in SharePoint Online with the command New-SPOSite.  PowerShell can also assign one or more owners to any SharePoint site making the entire process simple and efficient.

In this scenario we will illustrate how to create a single site with one defined owner.

Then we will show you how to bulk-add multiple SharePoint sites using the Import-CSV command.

SharePoint Online provides three default membership groups, Owners, Members, and Visitors; with Full Control, Contribute, and View-only site permissions respectively. A script to populate the groups with members has also been provided.

To aid you in this process we have included the following sample CSV files in the resource area.
1. List of sites with URLS and owners.                  (New SharePoint site sample CSV file)
2. List of sites, users and group memberships.   (New SharePoint group sample CSV file)


Note: Remember to substitute Name, URL, Owner, Site, Group & User information, in both the script and CSV examples, with your information.

Create multiple SharePoint site collections with different owners

To begin, you will need to load the SharePoint Online module to be able to run commands in PowerShell. You must also replace the url "https://contoso-admin.sharepoint.com" and use your SharePoint administrative site.
Import-Module Microsoft.Online.Sharepoint.PowerShell 
$credential = Get-credential 
Connect-SPOService -url https://contoso-admin.sharepoint.com -Credential $credential
Create a single new site collection using the minimum required values; URL, owner, and storage quota.
New-SPOSite -Url https://contoso.sharepoint.com/sites/NewSite -Owner user@contoso.com -StorageQuota 1024
Create a single new site collection, with a defined site owner, and site properties. Command will not wait for site creation to complete.
New-SPOSite -Url https://contoso.sharepoint.com/sites/NewSite -Owner user@contoso.com -StorageQuota 1024 -Title "Site Name" -CompatibilityLevel 15 -LocaleID 1033 -ResourceQuota 300 -Template "STS#0" -NoWait

The following command will import the content of the CSV, and create a site collection per row.
Create CSV file with following content (first line is header row) Name,URL,Owner,StorageQuota,ResourceQuota,Template

(see sample file in resource section)

Import-Csv .\NewSPOSites.csv| % {New-SPOSite -Owner $_.Owner -StorageQuota $_.StorageQuota -Url $_.Url -NoWait -ResourceQuota $_.ResourceQuota -Template $_.Template -Title $_.Name}

You must assign group members to site.
By default each site created from a standard template (eg. STS#0) is created with three membership groups, Owners, Members, and Visitors; with Full Control, Contribute, and View-only site permissions respectively.

(see sample file in resource section)

Import-Csv .\SPOUserGroups.csv| % {Add-SPOUser -Site $_.Site -Group $_.Group -LoginName $_.User}