Last active
September 30, 2016 15:42
-
-
Save rheid/4570b3e2e2139a15972c7b7c8197b957 to your computer and use it in GitHub Desktop.
SharePoint: Provisioning user profile service using PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue | |
# assume your farm account is managed account | |
$FarmSvcAccountName = "AD\YourFarmServiceAccount" | |
$FarmSvcAccount= (Get-SPManagedAccount $FarmSvcAccountName) | |
$DatabaseServer = "YourDBServer" | |
$AppServer = "YourAppServer" | |
$MySitePort = 85 | |
$MySiteUrl="http://{0}:{1}" -f $AppServer, $MySitePort | |
$MySiteWebAppName = "MySites" | |
$MySite_AppPool = "MySite_AppPool" | |
$MySiteDB = "MySite_DB" | |
$MySiteWebPath = "C:\Inetpub\MySites" | |
if ((Get-SPWebApplication | Where-Object { $_.DisplayName -eq $MySiteWebAppName}) -eq $null) | |
{ | |
Write-Host "Creating MySites Web App..." | |
# Step 1 | |
New-SPWebApplication -Name $MySiteWebAppName ` | |
-Url $MySiteUrl ` | |
-Path $MySiteWebPath ` | |
-DatabaseServer $DatabaseServer ` | |
-DatabaseName $MySiteDB ` | |
-ApplicationPool $MySite_AppPool ` | |
-ApplicationPoolAccount $FarmSvcAccount | |
Write-Host "Creating MySites Site Collection..." | |
# Step 2 | |
New-SPSite $MySiteUrl -Name "MySites" -OwnerAlias $FarmSvcAccountName -Template (Get-SPWebTemplate –identity SPSMSITEHOST#0) | |
Write-Host "Done." | |
} | |
else | |
{ | |
Write-Host "My Site WebApp [$MySiteUrl] already exists" -ForegroundColor Yellow | |
} | |
# Step 3 | |
StartServiceInstance "User Profile Service" | |
$ProfileServiceName = "Profile Service" | |
$ProfileAppPoolName = "ProfileAppPool" | |
$SocialDBName="SocialDB" | |
$ProfileDBName="ProfileDB" | |
$ProfileSyncDBName = "ProfileSyncDB" | |
$MySiteManagedPath="/sites" | |
$ProfileApp = Get-SPServiceApplication | Where-Object { $_.DisplayName -eq $ProfileServiceName } | |
if ($ProfileApp -eq $null) | |
{ | |
# Step 4 | |
$ProfileAppPool = Get-SPIisWebServiceApplicationPool | Where-Object { $_.Name -like "SharePoint Web Services Default" } | |
# Step 5 | |
Write-Host "Creating $ProfileServiceName ..." | |
$ProfileApp = New-SPProfileServiceApplication -Name $ProfileServiceName ` | |
-ApplicationPool $ProfileAppPool ` | |
-MySiteHostLocation $MySiteUrl ` | |
-MySiteManagedPath $MySiteManagedPath ` | |
-ProfileDBName $ProfileDBName ` | |
-ProfileDBServer $DatabaseServer ` | |
-SocialDBName $SocialDBName ` | |
-SocialDBServer $DatabaseServer ` | |
-ProfileSyncDBName $ProfileSyncDBName ` | |
-ProfileSyncDBServer $DatabaseServer | |
# Step 6 | |
Write-Host "Creating $ProfileServiceName Proxy..." | |
$ProfileAppProxy = New-SPProfileServiceApplicationProxy -Name $ProfileServiceName -ServiceApplication $ProfileApp -DefaultProxyGroup | |
Write-Host "Done." | |
} | |
else | |
{ | |
Write-Host "Profile Service Application [$ProfileServiceName] already exists." -ForegroundColor Yellow | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment