SharePoint 2013 User Profile Synchronization with PowerShell

Update Sep. 2014: Finished User Profile Service Application step-by-step guide + PowerShell scripts.

Get the E-Book + Scripts

I used 5 simple steps to enable User Profile Synchronization in SharePoint 2013. It isn’t magic and you only need to follow certain steps carefully so all required permissions are met.

If you get an error just paste it to a search engine and you will find a lot of help.


Here are the requirements I met:

  1. Successfully installing a SharePoint 2013 environment.
  2. I was logged on with the SharePoint Farm Account which was in the local Administrators Group. Both only for the purpose to successfully activate User Profile Synchronization. After that I removed the account from the local Administrators Group.
  3. I restarted the server after putting the SharePoint Farm Account in the local Administrators Group because of the security token to become active.
  4. I opened a PowerShell console using 'Run as administrator' to run the PowerShell script.

Setup User Profile Synchronization with PowerShell

Here are the steps to enable SharePoint 2013 User Profile Synchronization using PowerShell:

  1. Create a new Service Application. Btw the name of the application pool is sufficient here:
    $ups = New-SPProfileServiceApplication –Name "User Profile" 
        -ApplicationPool "Name of an Application Pool"  
    -ProfileDBServer "DB_SERVERNAME" -ProfileDBName "ProfilesDB"
    -SocialDBServer "DB_SERVERNAME" -SocialDBName "SocialDB"
    -ProfileSyncDBServer "DB_SERVERNAME" -ProfileSyncDBName "SyncDB"
    -MySiteHostLocation "URL_to_MySite_Host"
  2. Create a service application proxy:
    New-SPProfileServiceApplicationProxy -Name "User Profile Proxy" –DefaultProxyGroup 
  3. Get the instances of 2 services related to User Profile Synchronization from your SharePoint server (usually APP) where you want to run User Profile Sync:
    $service1 = $(Get-SPServiceInstance | 
    where {$_.TypeName -match "User Profile Service" } |
    where {$_.Server -match "SPServer Name=YOUR_APP_SERVERNAME"}) $service2 = $(Get-SPServiceInstance |
    where {$_.TypeName -match "User Profile Synchronization Service" } |
    where {$_.Server -match "SPServer Name=YOUR_APP_SERVERNAME"})
  4. Start the User Profile Service:
    Start-SPServiceInstance -Identity $service1.ID  
  5. Start the User Profile Synchronization Service:
    $ups.SetSynchronizationMachine("YOUR_APP_SERVERNAME", $service2.ID, 
    "domain\FarmAcc", "FarmAccPwd")
    -Identity $service2.ID
  6. Get the finished PowerShell script that is part of my book if you don't want to do it manually.

Now you have to wait since this takes 1 or 2 minutes.


The resources I used are from Spencer Harbar: