2015-05-28 51 views
1

我想要更改所有用戶的名爲Department的用戶配置文件屬性的編輯設置和顯示設置值。有人可以告訴我該怎麼做。使用powershell更改sharepoint 2010中所有用戶的用戶配置文件屬性

我可以通過這個PowerShell獲得部門屬性。現在這個屬性編輯設置是不允許用戶編輯這個屬性,我想讓它對每個用戶都是可編輯的。

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() 

感謝

回答

0

我猜你的意思是這個屬性,對不對?

enter image description here

以下腳本演示瞭如何設置Departments用戶配置文件屬性的IsUserEditable子屬性:

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") 
$subtypeProp.IsUserEditable = $true 
$subtypeProp.Commit() 

參考

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

相關問題