Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Use the UserProfileManager class to edit SharePoint user profile properties via PowerShell. You can use this method if you have deployed My Sites to your farm. To use this method, you must create an instance of the UserProfileManager based upon your farm's My Site deployment. here's how:
$mySiteUrl = "[My Site URL]" $adAccount = "DOMAIN\username" $site = Get-SPSite $mySiteUrl $context = Get-SPServiceContext $site $UserProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) $up=$UserProfileManager($adAccount)
To then edit a property, e.g., the name that is displayed for a user, you would write:
$pp = "First Middle Last" $up["PreferredName"].Value = $pp $up.commit()
To view a list of all user profile properties, just do:
$up.Properties | sort-object name | ft name,displayname,isalias -auto
To find out what you can do with these properties, just do:
$up.Properties | Get-Member
Not all of these properties are of type string and can be edited. I don't know what the rule is, but from my experience, those properties that do not begin with SPS can be edited and those that do cannot be edited.