首先将如下脚本保存为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. linux下bom头导致的php调用php接口 返回的json字符串 无法转成 数组,即json字符串无法解码的问题

    今天很是郁闷,写了一个php接口,返回的是标准的json字符串,但是调用的php 就是无法json_decode(),返回错误码为4,最后终于找到原因,原来是蒙一个文件中有bom头,最后采用一个命令 ...

  2. 【jq】c#零基础学习之路(3)继承和虚方法

    c#只能继承一个基类和多个接口(0+) 父类:Human: class Human { public virtual Move() { Console.WriteLine("Human的虚方 ...

  3. Kindle DXG和Win10 64bits无法连接的问题

    直入主题:换根数据线. 不要觉得答案简单,我就是不负责任的在调侃. 在得出这条答案之前,我的思路是,既然插上线以后,kindle的充电指示灯会亮,那就应该不是线的问题. 所以实际的过程是我安装了驱动之 ...

  4. Myeclipse添加外部Tomcat出现启动故障的问题解决

    故障: 1.java.lang.IllegalStateException: No output folder 分析:work文件夹无写权限 解决:找到tomcat的安装文件夹,右键点击work文件夹 ...

  5. easyui datagrid 动态添加columns属性

    公司在项目设计的时候,有一个需求,就是查出来的表的字段不唯一,一张表的字段可能是三个,也可能是五个,但是却要把它显示到页面,这个给我做ui的带来一点麻烦.因为以前一般用easyui 的datagrid ...

  6. js取整函数

    1.丢弃小数部分,保留整数部分parseInt(5/2) 2.向上取整,有小数就整数部分加1 Math.ceil(5/2) 3,四舍五入. Math.round(5/2) 4,向下取整 Math.fl ...

  7. Java后台判断请求来自PC端还是移动端

    核心代码

  8. [原创]cocos2d-x研习录-第三阶 多分辨率适配器

    在移动终端(智能手机)平台下开发游戏一般都会涉及到屏幕多分辨率适配问题,原因是手机款式多种多样,不同的款式存在有不同的尺寸,即使尺寸相同又可能存在不同的分辨率. 手机屏幕尺寸:指手机屏幕对角线长度. ...

  9. php7 编译安装 apache

    http://blog.csdn.net/21aspnet/article/details/47708763 根据此教程的步骤但是碰到了若干问题 1.  执行./configure的时候报错 大部分可 ...

  10. SSL/TLS算法流程解析

    SSL/TLS 早已不是陌生的词汇,然而其原理及细则却不是太容易记住.本文将试图通过一些简单图示呈现其流程原理,希望读者有所收获. 一.相关版本 Version Source Description ...