Creating the User Profile Service Application (UPA) via Powershell is a fairly straightforward process. We only have to follow these steps:
- Set Parameters
- Create the Service Application
- Create the Service Application Proxy and associate it to the Proxy Group
- Set Parameters: First of all we have to set the parameters we will use for the service application.
- Name for your User Profile Service Application
- $UPAName = “70331_UserProfile”
- Application Pool: You can create a specific one or use an existing one. I recommend to use the same Application Pool for all service applications. In my case, I am assigning the existing application pool called “ServiceApplications” to the $appPool variable:
- $AppPool = Get-SPServiceApplicationPool –Identity “ServiceApplications”
- Database Names: UPA uses three distinct databases: Profile, Social and Profile. Try to follow the convention rule you have for your farm databases. $SocialDB = “70331_UserProfile_SocialDB”
- $SyncDB = “70331_UserProfile_SyncDB”
- $ProfileDB = “70331_UserProfile_ProfileDB”
- Proxy Name: Type a name for the Proxy/connection of the UPA
- $UPAProxy = “70331_UPA_Proxy”
- Create the Service Application: Use the New-SPProfileServiceApplication cmdlet for this purpose and use the recently created parameters and collect the result in the $UPA variable so as to use it later in the Proxy creation.
$UPA=New-SPProfileServiceApplication -Name $UPAName -ApplicationPool $appPool -ProfileDBName $ProfileDB -SocialDBName $SocialDB -ProfileSyncDBName $SyncDB
- Create the Service Application Proxy: Use the New-SPProfileServiceApplicationProxy cmdlet and the parameters configured above. Use the option DefaultProxyGroup if you want to include the proxy into the default group.
New-SPProfileServiceApplicationProxy -Name $UPAProxy -ServiceApplication $UPA –DefaultProxyGroup
- If you did not associate the user profile proxy to the default proxy group and you want to associate it to a custom one, do the following:
#Get the list of Proxy Groups and copy the Friendly Name of the Proxy group you need.
Get-SPServiceApplicationProxyGroup
$proxyGroup=Get-SPServiceApplicationProxyGroup -Identity “Intranet Only”
#Get the list of proxies/connections, copy the typename of the UPA proxy and use it for assigning it to the $proxy variable
$proxy=Get-SPServiceApplicationProxy | ? {$_.TypeName -eq “User Profile Service Application Proxy”}
#Use the Add-SPServiceApplicationProxyGroupMember cmdlet to add the UPA proxy to your custom ProxyGroup
Add-SPServiceApplicationProxyGroupMember -Identity $proxygroup -Member $Proxy
That´s all, hope it helps!