首先将如下脚本保存为PowerShell文件,如:ReorderUserProfileProperty.ps1。

在执行此脚本时,如果不输入任何参数,将列出所有用户配置文件属性的名称和显示次序;如果只输入属性名称,则显示此属性的显示次序;如果输入了属性名称和显示次序,则修改此属性的显示次序。

####################################################################################
# Function: Re-order a user profile property, or show display order of a or all properties.
# Return: If $PropertyName is null, the display order of all properties will be shown.
# if $DisplayOrder is null, the display order of $PropertyName will be shown.
# Otherwise, the display order of $PropertyName will be re-ordered.
####################################################################################
param(
[string]$PropertyName,
[int]$DisplayOrder,
[string]$SiteUrl
) [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles.UserProfileManager")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") if(!$SiteUrl)
{
$SiteUrl = 'http://SharePointServer:80/'
} $site = new-object Microsoft.SharePoint.SPSite($SiteUrl);
$context = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);
if (!$context)
{
write-host "context is empty, quitting!"
break
} $UPAConfMgr = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context)
if (!$UPAConfMgr)
{
write-host "confmgr is empty, quitting!"
break
} $userprofiletype = [Microsoft.Office.Server.UserProfiles.ProfileType]::User
$userProfileSubTypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($context)
$userProfile = $userProfileSubTypeManager.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName($userprofiletype))
$userProfileProperties = $userProfile.Properties if($PropertyName)
{
$sec = $userProfileProperties.GetPropertyByName($PropertyName)
Write-Host 'Current Order: '$sec.DisplayOrder
}
else
{
$userProfileProperties | Format-Table -Property Name,DisplayOrder,DisplayName -AutoSize
} if ($DisplayOrder)
{
$userProfileProperties.SetDisplayOrderByPropertyName($PropertyName,$DisplayOrder)
Write-Host 'New Order: '$sec.DisplayOrder
} $userProfileProperties.CommitDisplayOrder()

在使用此结果过程中,可能会遇到如下问题,其解决办法如下:

1. 在执行脚本时提示如下错误:

New-Object : 使用“1”个参数调用“.ctor”时发生异常:“没有用户配置文件应用程序可用于处理请求。

【解决办法】:
办法一:在 管理中心 > 应用程序管理 > 管理服务应用程序 页面中,选中“User Profile Service Application”(但不要跳转),然后在Ribbon的“管理员”和“权限”中给当前用户赋予“Full Control”权限。
办法二:“以管理员身份运行”SharePoint 2010 Management Shell。

2. 管理用户属性页面显示异常

有时,在执行完脚本后  管理中心 > 应用程序管理 > 管理服务应用程序 > User Profile Service Application > 管理用户属性 页面会提示属性信息错误。

【解决办法】:在页面中对任意属性手工排序,则页面显示将恢复正常。

3. 属性显示次序不会自动重排

在修改某一属性的显示次序时,其他相邻属性的次序不会自动重排。因此,在用此脚本单独修改属性后,可能会出现相同显示次序的属性,从而达不到期望的显示次序。

【解决办法】:规划好各属性的显示次序后,按如下格式的脚本统一执行:

.\ReorderUserProfileProperty.ps1 MIS-StaffNo 11
.\ReorderUserProfileProperty.ps1 Department 12
.\ReorderUserProfileProperty.ps1 MIS-JobTitle 13
.\ReorderUserProfileProperty.ps1 SPS-JobTitle 14

参见:
http://www.sharepointstuffs.com/creating-managing-and-ordering-user-profile-properties-using-powershell-in-sharepoint-2013/
http://littletalk.wordpress.com/2010/12/09/no-user-profile-application-available-to-service-the-request/

【HOW】用PowerShell脚本修改用户配置文件属性显示次序的更多相关文章

  1. 【HOW】如何允许编辑用户配置文件属性

    在自定义用户配置文件属性后会发现,通过属性本身的配置页面,只能允许用户修改自己的属性,而管理员无法修改其他用户的属性.若要允许管理员在用户信息页面修改用户配置文件属性,可通过如下操作实现: 1. 进入 ...

  2. SharePoint 2013 开发——获取用户配置文件属性内容(User Profile)

    博客地址:http://blog.csdn.net/FoxDave 本篇我们应用SharePoint CSOM(.NET)来读取用户配置文件的信息,个人开始逐渐倾向于客户端模型,因为不用远程登录到 ...

  3. sharepoint 2013 更改用户配置文件属性值的方法 modify user profile

    在此前写了两篇文章sharepoint 的UserProfile博客 sharepoint 2010 获取用户信息UserProfile方法 sharepoint 2010 怎样用SocialComm ...

  4. 用PowerShell脚本实现对SharePoint页面Title的修改

    存在这样一种情况,对应的page已经部署到product的SharePoint环境中,那么在部署下一个版本的时候就不允许把已经创建好的page删除再创建,因此page中修改过的属性就不能再次部署到Sh ...

  5. 利用Nuget打包添加tools下intsall.ps1【powershell脚本】修改.csproj文件

    利用Nuget打包添加tools下intsall.ps1[powershell脚本]修改.csproj文件, 以设置1.项目-生成->输出->选择[XML文件文件] 2.项目->调试 ...

  6. windows创建隐藏用户的powershell脚本

    通过保存并重新注册已删除用户的注册表的方式来隐藏用户,未登录时登陆界面不可见,登陆后可见 方法详情见: https://www.k0rz3n.com/2018/06/26/windows%E6%B8% ...

  7. ss_port_change - 一键修改ss配置与Centos7的Firewall策略脚本

    ss_port_change 修改ss配置与Centos7的Firewall策略脚本 注意是否需要修改config路径与ss服务的名 脚本的敏感字用了*代替 项目地址 Github 脚本 #!/bin ...

  8. linux如何通过脚本来修改用户的密码?脚本自动化修改用户密码?

    需求描述: linux环境中在创建用户的时候,涉及到修改用户的密码,一般是通过passwd命令进行修改,需要多次的确认,这里考虑通过一条命令直接对密码进行修改 不需要进行交互的方式.在此记录. 操作过 ...

  9. linux中用户、组的管理(密码管理、权限管理及其修改用户、组)(转)

    process(进程) 1 计算资源 权限 用户(获取资源或服务的凭证或标识) 用户,容器,关联权限:用户组(标识符),方便地指派权限 2 用户.组.权限   安全上下文(secure context ...

随机推荐

  1. “添加到收藏夹”功能(share)

    以下分享自: 如何给网站增加“添加到收藏夹” 给网站添加“添加到收藏夹”理论上应该是很简单的事情,但是受到各种浏览器和操作系统的不一致的问题,使得这个问题异常的繁琐啊. 下面是梳理的一些资料,仅供参考 ...

  2. Outline of Apache Jena Notes

    1 description 这篇是语义网应用框架Apache Jena学习记录的索引. 初始动机见Apache Jena - A Bootstrap 2 Content 内容组织基本上遵循Jena首页 ...

  3. 0-Spark高级数据分析-读书笔记

    学完了<Spark快速大数据分析>,对Spark有了一些了解,计划更近一步,开始学习<Spark高级数据分析>.这本书是用Scala写的,在学习的过程中想把其中的代码转换成Ja ...

  4. JS对象实现随机满天小星星实例

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  5. QT5学习过程的小问题集锦

    *** only available with -std=c++11 or -std=gnu++11 添加以下代码到*.pro文件. CONFIG += c++11 在 Qt creator 中设置 ...

  6. Hello Docker (Docker 入门分享)

    Hello Docker 1 PPT @ http://download.csdn.net/download/liangread/9431056 TBD

  7. Git简易教程

    概述 在说明什么是git之前,我们需要对版本控制(Version Control)做一个基本的概述,一般情况下,我们的源代码都是在时间和空间两个维度上进行管理并维护的,代码本身以及组织代码的项目文件( ...

  8. C 语言中的优先级

    先看一段代码: /********************************************************************* * @fn bdAddr2Str * * ...

  9. 记一次ifconfig命令

    由于Windows 10的强制更新,原来的Virtual box Host-Only驱动莫名奇妙的不见了,于是上网找各种解决方案: 1.重新生成虚拟网卡适配器:执行 VBoxManage.exe ho ...

  10. 单因素特征选择--Univariate Feature Selection

    An example showing univariate feature selection. Noisy (non informative) features are added to the i ...