Recently, I have been very busy building a new product, and been playing a lot with the new (and old) Office 365 APIs and everything around it. The product is cloud based and in a multi-tenant distribution model. I will be blogging more often about the experience and challenges I faced.
Being a multi-tenant product that will be deployed many times, Automating it was the first thing to cross my mind.
I am using PowerShell scripts to create a site collection which will act as the datasource for my app.
# 1- get the credentials
# 2- Connect to the adminstration service
# 3- Create the site collection using the New-SPOSite commandlet
$adminAccount = 'email@example.com'
$credentials = Get-Credential -UserName $adminAccount -Message "Enter SharePointOnline credentials"
Connect-SPOService -Url 'https://tenant-admin.sharepoint.com'
echo 'Connected to Admin Service....'
New-SPOSite -Url 'https://tenant.sharepoint.com/sites/collaboration'
echo 'Created SiteCollection'
The code is very straight forward three steps:
- Get the credentials
- Connect to the admin service
- Create the new site