In my situation the user was originally sync'd from Active Directory, but we had some OU changes and broke the hierarchy.
It's PowerShell to the rescue!
This example will retrieve a user profile from the web application, and updates the preferred name and user manager.
#Set up default variables
$mySiteUrl = "http://mysites"
$adAccount = "DOMAIN\username"
$upAttribute = "PreferredName"
$upAttributeValue = "My New Name"
#Get site objects and connect to User Profile Manager service
$site = Get-SPSite $mySiteUrl
$context = Get-SPServiceContext $site
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
#Check to see if user profile exists
if ($profileManager.UserExists($adAccount))
{
#Get user profile and change the value
$up = $profileManager.GetUserProfile($adAccount)
$up["PreferredName"]
$up["Manager"]
#$up["PreferredName"].Value = $upAttributeValue
#$up.Commit()
$up["Manager"].Value = "DOMAIN\manager"
$up.Commit()
}
else
{
write-host "Profile for user"$adAccount "cannot be found"
}
#Dispose of site object
$site.Dispose()
No comments:
Post a Comment