Add-PSSnapin Microsoft.SharePoint.PowerShell
$siteUrl = "Site URL"
#$accountName = "i:0#.f|fba|test" # Account name if FBA user
$accountName = "Domaine\UserID"
$site = Get-SPSite $siteUrl
$context = Get-SPServiceContext($site)
$pm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
# If user profile doesn't exist create new one
if ($pm.UserExists($accountName)) {
$userProfile = $pm.GetUserProfile($accountName)
} else {
$userProfile = $pm.CreateUserProfile($accountName)
}
# Update user profile properties
$userProfile["FirstName"].Value = "FName"
$userProfile["LastName"].Value = "LName"
$userProfile["WorkPhone"].Value = "PhNo"
$userProfile["Title"].Value = "Developer"
$userProfile["WorkEmail"].Value = abc@abc.com
$userProfile["Department"].Value = "Sales"
$userProfile["SPS-MUILanguages"].Value = "en-us"
# Commit changes
$userProfile.Commit()
#Clear our User Profile Cache
Use-CacheCluster
Restart-CacheCluster
No comments:
Post a Comment