How to create Office 365 Tenant Provisioning and Management in SharePoint


To create a tenant, follow the steps in the table.

1. Create a site subscription.

$sub = New-SPSiteSubscription
Set-SPSiteSubscriptionConfig -id $sub -FeaturePack $customerFeatures -UserAccountDirectoryPath “OU=$customerName,OU=Customers,DC=contoso,DC=com”

2. Assign a feature pack to the site subscription and configure custom OU by using People Picker.

Write-Host “Creating Member Site…”
New-SPSite -url “http://$customerName.contoso.com”; -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -owneremail $customerTenantAdminEmail -template sts#0 -ContentDatabase $contentDBName

3. Create one or more site collections to be assigned to the site subscription.

# create Tenant Admin site
Write-Host “Creating Tenant Admin site…”
New-SPSite -url “http://$customerName.contoso.com/admin”; -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -owneremail $customerTenantAdminEmail -template tenantadmin#0 -AdministrationSiteType TenantAdministration -ContentDatabase $contentDBName

Write-Host “Creating My Site Host…”
New-SPSite -url “http://$customerName.contoso.com/mysites”; -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -owneremail $customerTenantAdminEmail -template SPSMSITEHOST#0 -ContentDatabase $contentDBName

The following Windows PowerShell script shows how to create a tenant admin site that uses the TENANTADMIN#0 template. If the tenant is configured to use an Enterprise Feature Pack, the Windows PowerShell script performs additional operations, that is, it creates the My Sites collection.
Add-PSSnapin Microsoft.SharePoint.Powershell -EA 0

# farm details (update to reflect your environment)
$hostingMainURL = “http://$ENV:COMPUTERNAME”;
$upaProxyName = “Tenant User Profile Service Proxy”
$mmsProxyName = “Tenant Managed Metadata Service”
$contentDBName = “HostingFarm_Content_Hosting”

$farm = Get-SPFarm
$foundationFeaturePack = $farm.Properties.Foundation_FeaturePack
#$standardFeaturePack = $farm.Properties.Standard_FeaturePack
#$enterpriseFeaturePack = $farm.Properties.Enterprise_FeaturePack

# tenant-specific information (vary by tenant)
$customerName = “Customer A”
$customerTenantAdmin = “CONTOSO\customerA-Admin”
$customerTenantAdminEmail = “admin@customerA.com
$customerFeatures = $enterpriseFeatures
# Note:
# this script assumes that the Content Web App and necessary Managed Paths exist.

# grab the web app
$webApp = Get-SPWebApplication $hostingMainURL

# create new Site Subscription
Write-Host “Creating Site Subscription…”
$sub = New-SPSiteSubscription

# assign feature pack and set the OU to be used by the People
Write-Host “Assigning Feature Pack and configuring People Picker…”
Set-SPSiteSubscriptionConfig -id $sub -FeaturePack $customerFeatures -UserAccountDirectoryPath “OU=$customerName,OU=Customers,DC=contoso,DC=com”

# create the “main” member site (we need a site at the root to use Host Headers and Managed Paths in the following cmdlets)
Write-Host “Creating Member Site…”
New-SPSite -url “http://$customerName.contoso.com”; -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -owneremail $customerTenantAdminEmail -template sts#0 -ContentDatabase $contentDBName

# create Tenant Admin site
Write-Host “Creating Tenant Admin site…”
New-SPSite -url “http://$customerName.contoso.com/admin”; -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -owneremail $customerTenantAdminEmail -template tenantadmin#0 -AdministrationSiteType TenantAdministration -ContentDatabase $contentDBName

# everything else needs standard
if (!($customerFeatures -eq $foundationFeatures))
{
Write-Host “Tenant has SharePoint Server features”
# create a mysite host
Write-Host “Creating My Site Host…”
New-SPSite -url “http://$customerName.contoso.com/mysites”; -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -owneremail $customerTenantAdminEmail -template SPSMSITEHOST#0 -ContentDatabase $contentDBName

# configure the MySites host, MySites path, Naming Resolution and Profile Sync OU for the Subscription
Write-Host “Configuring Tenant Profile Config…”
$upaProxy = Get-SPServiceApplicationProxy | where-object {$_.DisplayName -eq $upaProxyName}
Add-SPSiteSubscriptionProfileConfig -id $sub -SynchronizationOU $customerName -MySiteHostLocation “http://$customerName.contoso.com/mysites”; -MySiteManagedPath “/mysites/personal” -SiteNamingConflictResolution “None” -ProfileServiceApplicationProxy $upaProxy

# create a site for the Content Type Gallery
Write-Host “Creating Content Type Gallery…”
New-SPSite -url “http://$customerName.contoso.com/cthub”; -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -owneremail $customerTenantAdminEmail -template sts#0 -ContentDatabase $contentDBName

# configure the Content Type Gallery for the Subscription
Write-Host “Configuring Tenant Content Type Gallery…”
$mmsProxy = Get-SPServiceApplicationProxy | where-object {$_.DisplayName -eq $mmsProxyName}
# ContentTypeHub feature activation may fail – if so activate manually
Set-SPSiteSubscriptionMetadataConfig -identity $sub -serviceProxy $mmsProxy -huburi “http://$customerName.contoso.com/cthub”; -SyndicationErrorReportEnabled
Write-Host “Activating Content Type Hub…”
Enable-SPFeature -Identity ContentTypeHub -url “http://$customerName.contoso.com/cthub”;
}

Write-Host “Tenant Provisioning Script Completed!”

This approach can be further customized to contain other tenant configuration such as for Workflow, Apps and IRM. Generally such script is encapsulated into a function or custom cmdlets which enables it to be run repeatedly for future tenants.


Hope you enjoyed reading it.

Please don't forget to Share, Follow and Like to get updated with latest posts.

It gives me motivation to share more knowledge with you.


About Author

Satyendra Mishra

Project Management Professional (PMP) and Microsoft certified, motivated, energetic and accomplished Project Manager / Architect with 15+ years of work experience in Management, Architecture, Analytics, Development and Maintenance. I have been fortunate to be a part of over 25+ .Net / SharePoint projects delivery with various companies across different industry sectors. This has provided me a valuable insight and experience especially in successful implementation of SharePoint based solutions.

My experience in Web application implementation includes technology strategy and road-map definition, business and technical requirements identification, governance, platform architecture, solution design, configuration, development, quality assurance, training, post-production support, team lead and overall project delivery along with project management.

Satyendra Mishra holds a B.Tech. in Computer Science & Engineering and PG Diploma in Advance Computing from Center for Development and Advance Computing, Pune, India. He is also a certified Project Management Professional (PMP).

I love to share Project Management Tips and Tricks by writing Blogs in the Project Management India Community. I have written around 300+ articles in the Project Management, .Net, SharePoint and related client side technologies.

Related Posts

Leave a Reply

Your email address will not be published.