Skip to content

Instantly share code, notes, and snippets.

@zplume
Last active July 26, 2018 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zplume/527fe5437ff3f1232d71a5c69843343c to your computer and use it in GitHub Desktop.
Save zplume/527fe5437ff3f1232d71a5c69843343c to your computer and use it in GitHub Desktop.
# This script creates a set of modern team sites without an associated Group from a CSV file,
# using the New-SPOModernTeamSite.ps1 script.
# The script must be run from the SharePoint Online Management Shell and
# you must connect to your SharePoint tenant admin URL with Connect-SPOService before running it.
param(
# Path: Path/File name of a CSV file that contains populated Title, Url, Owner and AdditionalOwner columns
[Parameter(Mandatory = $true)]
[string]$Path
)
$ErrorActionPreference = "Stop"
# Load CSV file
$sites = Import-Csv -Path $Path
Write-Host -f Green "`n$Path loaded`n"
# Create sites
$sites | ForEach-Object {
Write-Host -NoNewline "Title: "
Write-Host -f White $_.Title
Write-Host -NoNewline "Url: "
Write-Host -f Yellow $_.Url
Write-Host -NoNewline "Owner: "
Write-Host -f Cyan $_.Owner
Write-Host -NoNewline "AdditionalOwner: "
Write-Host $_.AdditionalOwner
Write-Host " - Creating site"
.\New-SPOModernTeamSite.ps1 -SiteTitle $_.Title -SiteUrl $_.Url -OwnerAccountName $_.Owner
Write-Host " - Assigning additional owner"
Set-SPOUser -Site $_.Url -LoginName $_.AdditionalOwner -IsSiteCollectionAdmin $true | Out-Null
Write-Host
}
# This script creates a modern team site without an associated Group.
# The script must be run from the SharePoint Online Management Shell and
# you must connect to your SharePoint tenant admin URL with Connect-SPOService before running it.
param(
[Parameter(Mandatory = $true)]
[string]$SiteTitle,
[Parameter(Mandatory = $true)]
[string]$SiteUrl,
[Parameter(Mandatory = $true)]
[string]$OwnerAccountName
)
# LocaleID 2057 is not supported at site creation time and must be applied at the web level
New-SPOSite -Url $SiteUrl -Owner $OwnerAccountName -LocaleID 1033 -ResourceQuota 0 -Template "STS#3" -TimeZoneId 2 -Title $SiteTitle -StorageQuota 1024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment