Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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(
     $distinguishedName, 
     $domainName, 
     $isDomain: #> $false, 
     $partitionId, 
     $containersIncluded, 
     $containersExcluded, 
     $preferredDomainControllers, 
     $useOnlyPreferredDomainControllers,
 $isConfigurationNamingContext) 

// creating the list of naming context
$listOfNamingContext.Add($context1);
$listOfNamingContext.Add(...);

// 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)
{
    $configManager.ConnectionManager.AddActiveDirectoryConnection(
        [Microsoft.Office.Server.UserProfiles.ConnectionType]::ActiveDirectory, 
        $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?

share|improve this question
    
Have you found the answer to this that you can provide? Or can you edit the question with any more information? Thanks! –  Alex Angas Jun 1 '11 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 Jul 6 '11 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 Jul 8 '11 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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