Tuesday, September 6, 2016

Create My Site Host Site Collection for SharePoint 2016 using PowerShell

My Site host is a prerequisite for configuring user profile service application in SharePoint (Although you can provide My site host URL later, its a best practice to have it ready prior creating user profile service application). Creating My Site Host in SharePoint involves following steps:

  1. Create a new web application for My Site
  2. Create "Personal" wildcard Managed Path for the web application
  3. Enable Self-Service Site Creation for the web app
  4. Create a root site collection using My Site Host template
  5. In User Profile Service Application, configure My Site Host location
How to Create Mysite host using PowerShell in SharePoint?
Lets setup mysite host for SharePoint in four steps. Here is my PowerShell script to create Web application and My site Host Site Collection for SharePoint 2016:

Step 1: Create a Web application for My Site: 
Although you can use any existing web application for my site host in sharepoint 2016, lets create a new web application to host my sites.
#PowerShell to create a web application
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Define Variables for Web Application Creation
$WebAppName = "Crescent Mysite"
$HostHeader = "mysite.Crescent.com"
$WebAppURL="http://" + $HostHeader
$WebAppPort = "80"
$ContentDBName = "Crescent_MySite_Content"
$AppPoolName = "MySite Web Application AppPool"
$AppPoolAccount = "Crescent\SP16_AppPool"

#Authentication Provider
$AuthProvider = New-SPAuthenticationProvider 

#Check if Managed account is registered already
Write-Host -ForegroundColor Yellow "Checking if the Managed Accounts already exists"
$AppPoolAccount = Get-SPManagedAccount -Identity $AppPoolAccount -ErrorAction SilentlyContinue
if($AppPoolAccount -eq $null)
    Write-Host "Please Enter the password for the App Pool Account..."
    $AppPoolCredentials = Get-Credential $AppPoolAccount
    $AppPoolAccount = New-SPManagedAccount -Credential $AppPoolCredentials

#Create new Web Application
New-SPWebApplication -name $WebAppName -port $WebAppPort -hostheader $HostHeader -URL $WebAppURL -ApplicationPool $AppPoolName -ApplicationPoolAccount (Get-SPManagedAccount $AppPoolAccount) -AuthenticationMethod NTLM -AuthenticationProvider $AuthProvider -DatabaseName $ContentDBName

Step 2: Create "Personal" Managed Path:
#Create Managed Path for My Site Web application
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Define Parameters 
$WebAppURL = "http://mysite.Crescent.com"
$WebApp = Get-SPWebApplication $WebAppURL

#Add Managed Path
New-SPManagedPath "Personal" -WebApplication $WebAppURL -Explicit 

Step 3: Enable Self Service Site Creation for My Site Web Application:
#Enable Self service site creation
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Set Parameters 
$WebAppURL = "http://mysite.Crescent.com"
$WebApp = Get-SPWebApplication $WebAppURL

#Enable Self Service Site collection
$webApp.SelfServiceSiteCreationEnabled = $true
$webApp.RequireContactForSelfServiceSiteCreation = $false

Step 4: Create My Site Host Site Collection:
As far final step, lets create SharePoint Mysite host site collection using mysite host template.
#Create My Site Host Site collection
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Set Parameters for My Site Host Site Collection Creation
$WebAppURL = "http://mysite.Crescent.com"
$WebApp = Get-SPWebApplication $WebAppURL

#Create My Site Host site collection
New-SPSite -Name "My Site Host" -Url $WebAppURL -Template "SPSMSITEHOST#0" -OwnerAlias $FarmAdminAccount -ContentDatabase $Contentdatabase
Once all these steps are completed, confirmed from SharePoint Central Admin, my site host web application and site collections are listed
sharepoint create mysite host
SharePoint 2016 my site host URL is ready! now what? Set My Site Host location in your user profile service application! If want to change mysite host URL, refer How to change My site host location in SharePoint?

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...