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:
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.
To then edit a property, e.g., the name that is displayed for a user, you would write:$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 view a list of all user profile properties, just do:$pp = "First Middle Last" $up["PreferredName"].Value = $pp $up.commit()
To find out what you can do with these properties, just do:$up.Properties | sort-object name | ft name,displayname,isalias -auto
$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.
No comments:
Post a Comment