Hello,
I am trying to map a custom user profile property i created "ADSecurityGroups", type - String, Multivalue with the AD propoerty named "memberOf" via powershell.
UserProfile Service is up and running, and so is the Synchronization Service. User executing the powershell has full control on the User Profile Service and is the farm administrator.
Following is the code snippet i grabbed from the internet which i am trying to execute.
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction "SilentlyContinue"$url = "http://<servername:port>/" #URL of any site collection that is associated to the user profile service application.
$spsProperty = "ADSecurityGroups" #Internal name of the SharePoint user profile property
$fimProperty = "memberOf" #Name of the attribute in FIM/LDAP source
$connectionName = "UserProfileSyncConnection" #Name of the SharePoint synchronization connection
$site = Get-SPSite $url
if ($site)
{
Write-Host "Successfully obtained site reference!"
}
else
{
Write-Host "Failed to obtain site reference"
}
$serviceContext = Get-SPServiceContext($site)
if ($serviceContext)
{
Write-Host "Successfully obtained service context!"
}
else
{
Write-Host "Failed to obtain service context"
}
$upManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($serviceContext)
if ($upManager)
{
Write-Host "Successfully obtained user profile manager!"
}
else
{
Write-Host "Failed to obtain user profile manager"
}
$synchConnection = $upManager.ConnectionManager[$connectionName]
if ($synchConnection)
{
Write-Host "Successfully obtained synchronization connection!"
}
else
{
Write-Host "Failed to obtain user synchronization connection!"
}
Write-Host "Adding the attribute mapping..."
$synchConnection.PropertyMapping.AddNewMapping([Microsoft.Office.Server.UserProfiles.ProfileType]::User, $spsProperty, $fimProperty)
Write-Host "Done!"
The script is failing with the following error -
new-object : Exception calling ".ctor" with "1" argument(s): "UserProfileApplicationNotAvailableException_Logging ::UserProfileApplicationProxy.ApplicationProperties ProfilePropertyCache does not have 2f9bece3-f39a-498d-874f-145b1470e49c"
At E:\ADSync.ps1:29 char:14
+ $upManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigMa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
Please let me know if i am missing anything.
Also advise if this is the correct way to map user profile attribute in SP 2013 ?
Thanks -
Girish