4

I want to change the edit setting and Display setting value of a user profile property called Department for all users. Can someone please tell me how to do it.

I can get to the department property with this powershell. Right now this Property Edit Setting is DO not Allow Users to edit this property and I want to make it Editable for every user.

Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue
$mySiteUrl = "http://www.test.com/mysite"
$site = Get-SPSite $mySiteUrl
$context = Get-SPServiceContext $site
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$userProfile = $profileManager.GetUserProfile("Test\822");
$userProfile.Properties | sort DisplayName | FT DisplayName,Name,@{Label="Type";Expression={$_.CoreProperty.Type}}
$userProfile["Department"].Value 
$site.Dispose()

Thanks

1

The following script demonstrates how to set IsUserEditable sub property to Allow users to edit values for this property of Departments user profile property:

if ((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null)
{
    Add-PsSnapin Microsoft.SharePoint.PowerShell
}


$siteUrl = "http://contoso.intranet.com/"

$site = Get-SPSite $siteUrl
$context = Get-SPServiceContext($site)


$profileConfigMgr = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context) 
$profilePropMgr = $profileConfigMgr.ProfilePropertyManager
$subtypePropMgr = $profilePropMgr.GetProfileSubtypeProperties("UserProfile")
$subtypeProp = $subtypePropMgr.GetPropertyByName("Department")
$coreProp = $subtypeProp.CoreProperty
$typeProp = $subtypeProp.TypeProperty

$subtypeProp.IsUserEditable = $true
$subtypeProp.Commit()

References

How to: Work with user profiles and organization profiles by using the server object model in SharePoint 2013

0

Instead of using PowerShell, you can edit these settings in Central Administration GUI, before you cahnge the department values with PowerShell.

You need to remove the import property mapping and add an export property mapping on the department attribute. Navigate to your User Profile Service Application and follow the link Manage User Properties. Chose to Edit the Department property.

I the section "Edit Settings" select "Allow users to edit values for this property".

enter image description here

In the section "Property Mapping for Synchronization" remove the Import mapping and add a new mapping, to the same attribute (department) and set the direction to Export.

enter image description here

This means that changes are allowed from SharePoint to Active Directory, and that changes to this property in AD will be written over by SharePoint upon change (and synchronization).

When this is done, you can run your PowerShell script and set the department property.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.