forked from colinjwood/CodeCobra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateSiteCollection.ps1
30 lines (24 loc) · 1.22 KB
/
createSiteCollection.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<#
This script prompt creates a new site collection in your Office 365 tenant
The user is prompted for the SharePoint Site Collection url, Site Owner and TimeZone of the newly created
Site Collection and the site template used is the team site.
These values could be hardcoded as well without prompting.
#>
try {
Set-ExecutionPolicy Bypass -Scope Process
#Prompt for Tenant url
$TenantUrl = Read-Host -Prompt 'Enter your SharePoint online tenant url'
Connect-pnpOnline -url $TenantUrl
#Prompt for SharePoint Url
$SharePointUrl = Read-Host -Prompt 'Enter the url of your brand new site collection'
#Prompt for SharePoint Site Owner (email address)
$SiteOwner = Read-Host -Prompt 'Enter the site owner of your brand new site collection'
#Prompt for timezone of newly created site collection (enter id number)
Get-PnPTimeZoneId | Out-Host
$TZone = Read-Host -Prompt 'Choose timezone id based on values above'
#Create site collection based on team site template
New-PnPTenantSite -Owner $SiteOwner -Title 'Brand new site collection' -Url $SharePointUrl -Template 'STS#0' -TimeZone $TZone
}
catch {
Write-Host $error[0].Message
}