I'm trying to achieve a full User Profile setup for SharePoint 2010 using PowerShell, including the creation of the Active Directory connection.

My PowerShell source code comes mainly from here.

// define naming contexts
$context1 = new-object UserProfiles.DirectoryServiceNamingContext(
     $isDomain: #> $false, 

// creating the list of naming context

// then create the connection
$serviceContext = Get-SPServiceContext // can be seen in the url given above
$configManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($serviceContext)

if($configManager.ConnectionManager.Contains($connectionName) -eq $false)
        $connectionName, $domainName, <# useSSL: #> $false, 
        $userDomain, $userName, $password, 
        <# namingContexts #> $listOfNamingContext, 
        <# spsClaimProviderTypeValue: #> $null, 
        <# spsClaimProviderIdValue: #> $null)

Everything works fine except that run profiles for this connection are not created. Is this normal? When I create the same connection through SharePoint Central Admin, run profiles are created as in the following screenshot:

enter image description here

Do I need to create them programmaticaly or is there a problem? I've created one manually and the management agent works. And if I need to create them manually, how do I do this?

  • Have you found the answer to this that you can provide? Or can you edit the question with any more information? Thanks!
    – Alex Angas
    Commented Jun 1, 2011 at 5:06
  • There are some bugs with provisioning the user profile service application with PowerShell in that it doesn't do everything that Central Admin does. What I have found to usually work is to create the UPA with PowerShell but to start the services in Central Admin. Don't forget you need to have the farm account added to the local Administrators group when creating/starting the UPA and sync so that it has the permissions needed (another bug). Remove the account once the service is set up.
    – shufler
    Commented Jul 6, 2011 at 16:32
  • Indeed, I spotted some bugs with powershell. As you said, I needed to do some tasks directly in CA with farm account. But my primary objective was to be able to test prerequisites, create UPA, create AD connection "automatically" without so much manual steps in powershell. Seems to be impossible (or really complex) for the time being.
    – camous
    Commented Jul 8, 2011 at 8:59

1 Answer 1


The UPA/UPS master appears to have your answer: http://www.harbar.net/archive/2011/07/12/332.aspx

Also, be aware that SP1 did not fix the Sync DB schema issue when provisioned via Powershell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.