Tuesday, September 6, 2016

Create My Site Host Site Collection for SharePoint 2016 using PowerShell

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

PowerShell script to create Web application and My site Host Site Collection for SharePoint 2016:

Step 1: Create a Web application for My Site:
#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
$webApp.Update()


Step 4: Create My Site Host Site Collection:
#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"
$FarmAdminAccount="Crescent\SP16_Farm"
$Contentdatabase="Crescent_MySite_Content"
$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, make sure you set My Site Host location in your user profile service application!



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


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...