Create User Profile Service Application using PowerShell in SharePoint 2016
We need User Profile Service Application to consume social features in SharePoint 2016 such as My Sites, User profiles, etc. This PowerShell script creates User Profile Service Application in SharePoint 2016.
PowerShell to create user profile service application in SharePoint 2016
Next step: As for next step, Configuring user profile Import or synchronization by Create a user profile connection and starting a full profile import. Here is how to add new connection for user profile import: How to Add a user profile synchronization connection in SharePoint 2016?
Prerequisite: Create my site host prior creating user profile service application.Create My site host using PowerShell in SharePoint
PowerShell to create user profile service application in SharePoint 2016
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Configuration Parameters $ServiceAppName = "User Profile Service Application" $ServiceAppProxyName = "User Profile Service Application Proxy" $AppPoolAccount = "Crescent\SP16_Pool" $AppPoolName = "Service Application App Pool" $DatabaseServer ="SP16-SQL" $UserProfileDB = "Farm_Profile_DB" $UserProfileSyncDB = "Farm_Profile_Sync_DB" $UserProfileSocialDB = "Farm_Profile_Social_DB" $MySiteHostLocation="http://mysite.crescent.com/" Try { #Set the Error Action $ErrorActionPreference = "Stop" #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 Service Account..." $AppPoolCredentials = Get-Credential $AppPoolAccount $AppPoolAccount = New-SPManagedAccount -Credential $AppPoolCredentials } #Check if the application pool exists already Write-Host -ForegroundColor Yellow "Checking if the Application Pool already exists" $AppPool = Get-SPServiceApplicationPool -Identity $AppPoolName -ErrorAction SilentlyContinue if ($AppPool -eq $null) { Write-Host -ForegroundColor Green "Creating Application Pool..." $AppPool = New-SPServiceApplicationPool -Name $AppPoolName -Account $AppPoolAccount } #Check if the Service application exists already Write-Host -ForegroundColor Yellow "Checking if User Profile Service Application exists already" $ServiceApplication = Get-SPServiceApplication -Name $ServiceAppName -ErrorAction SilentlyContinue if ($ServiceApplication -eq $null) { Write-Host -ForegroundColor Green "Creating User Profile Service Application..." $ServiceApplication = New-SPProfileServiceApplication -Name $ServiceAppName -ApplicationPool $AppPoolName -ProfileDBName $UserProfileDB -ProfileSyncDBName $UserProfileSyncDB -SocialDBName $UserProfileSocialDB -MySiteHostLocation $MySiteHostLocation } #Check if the Service application Proxy exists already $ServiceAppProxy = Get-SPServiceApplicationProxy | where { $_.Name -eq $ServiceAppProxyName} if ($ServiceAppProxy -eq $null) { #Create Proxy $ServiceApplicationProxy = New-SPProfileServiceApplicationProxy -Name $ServiceAppProxyName -ServiceApplication $ServiceApplication -DefaultProxyGroup } #Start service instance $ServiceInstance = Get-SPServiceInstance | Where-Object { $_.TypeName -eq "User Profile Service" } #Check the Service status if ($ServiceInstance.Status -ne "Online") { Write-Host -ForegroundColor Yellow "Starting the User Profile Service Instance..." Start-SPServiceInstance $ServiceInstance } Write-Host -ForegroundColor Green "User Profile Service Application created successfully!" } catch { Write-Host $_.Exception.Message -ForegroundColor Red } finally { #Reset the Error Action to Default $ErrorActionPreference = "Continue" }Once the script execution completed successfully, you can go to Central Administration >> Application Management >> Service Application Page to verify user profile service application is created.
Next step: As for next step, Configuring user profile Import or synchronization by Create a user profile connection and starting a full profile import. Here is how to add new connection for user profile import: How to Add a user profile synchronization connection in SharePoint 2016?
Create User Profile Service Application using PowerShell in SharePoint 2016
Reviewed by Salaudeen Rajack
on
August 24, 2017
Rating:

Hello Salaudeen,
ReplyDeletejust found your blog - and I'm quite happy I did. As a beginner the script helps me understand things quicker :-)
Thanks again and greetings from Germany
Tobias
Awcum Salaudeen,
ReplyDeleteI read your all articles ,honestly your great jobs,If you don't mind I want to request to you please create a separate label of article for SP RestAPI with real word scenario based.