【HOW】用PowerShell脚本修改用户配置文件属性显示次序
首先将如下脚本保存为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脚本修改用户配置文件属性显示次序的更多相关文章
- 【HOW】如何允许编辑用户配置文件属性
在自定义用户配置文件属性后会发现,通过属性本身的配置页面,只能允许用户修改自己的属性,而管理员无法修改其他用户的属性.若要允许管理员在用户信息页面修改用户配置文件属性,可通过如下操作实现: 1. 进入 ...
- SharePoint 2013 开发——获取用户配置文件属性内容(User Profile)
博客地址:http://blog.csdn.net/FoxDave 本篇我们应用SharePoint CSOM(.NET)来读取用户配置文件的信息,个人开始逐渐倾向于客户端模型,因为不用远程登录到 ...
- sharepoint 2013 更改用户配置文件属性值的方法 modify user profile
在此前写了两篇文章sharepoint 的UserProfile博客 sharepoint 2010 获取用户信息UserProfile方法 sharepoint 2010 怎样用SocialComm ...
- 用PowerShell脚本实现对SharePoint页面Title的修改
存在这样一种情况,对应的page已经部署到product的SharePoint环境中,那么在部署下一个版本的时候就不允许把已经创建好的page删除再创建,因此page中修改过的属性就不能再次部署到Sh ...
- 利用Nuget打包添加tools下intsall.ps1【powershell脚本】修改.csproj文件
利用Nuget打包添加tools下intsall.ps1[powershell脚本]修改.csproj文件, 以设置1.项目-生成->输出->选择[XML文件文件] 2.项目->调试 ...
- windows创建隐藏用户的powershell脚本
通过保存并重新注册已删除用户的注册表的方式来隐藏用户,未登录时登陆界面不可见,登陆后可见 方法详情见: https://www.k0rz3n.com/2018/06/26/windows%E6%B8% ...
- ss_port_change - 一键修改ss配置与Centos7的Firewall策略脚本
ss_port_change 修改ss配置与Centos7的Firewall策略脚本 注意是否需要修改config路径与ss服务的名 脚本的敏感字用了*代替 项目地址 Github 脚本 #!/bin ...
- linux如何通过脚本来修改用户的密码?脚本自动化修改用户密码?
需求描述: linux环境中在创建用户的时候,涉及到修改用户的密码,一般是通过passwd命令进行修改,需要多次的确认,这里考虑通过一条命令直接对密码进行修改 不需要进行交互的方式.在此记录. 操作过 ...
- linux中用户、组的管理(密码管理、权限管理及其修改用户、组)(转)
process(进程) 1 计算资源 权限 用户(获取资源或服务的凭证或标识) 用户,容器,关联权限:用户组(标识符),方便地指派权限 2 用户.组.权限 安全上下文(secure context ...
随机推荐
- Mac 配置Spark环境scala+python版本(Spark1.6.0)
1. 从官网下载Spark安装包,解压到自己的安装目录下(默认已经安装好JDK,JDK安装可自行查找): spark官网:http://spark.apache.org/downloads.html ...
- PP 创建BOM
转自 http://blog.csdn.net/u012369651/article/details/19190939 一.最终结果预览. 二.创建过程. 使用到的事务码 CS01 创建BOM CS0 ...
- 请求网络get
package com.baidu.net; import java.io.IOException; import org.apache.http.HttpEntity;import org.apac ...
- 《C标准库》——之<string.h>
<string.h>里的字符串操作函数是经常要用到的,因此阅读了源码后自己实现了一些: 拷贝函数 void * Mymemcpy(void * sDst, const void * sSr ...
- Facebook 网络模拟工具 ATC部署及使用
废话引用: Facebook此前开源了增强网络流量控制工具 ATC,能利用WiFi网络模拟各种移动网络,测试智能手机和APP在不同国家地区和应用环境下的性能表现.ATC能够模拟2G.2.5G(Edge ...
- 每瓶啤酒2元,2个空酒瓶或4个瓶盖可换1瓶啤酒。10元最多可喝多少瓶啤酒? php
//根据题意设定初始变量值//然后 一个while循环去操作//每换得一个瓶子,换的那个减去要做相应的数目//然后喝了啤酒后, 各数量加1//直到不符合要求.跳出循环 1 class Beer{ pr ...
- python学习之关键字
1.assert 语句形式:assert 布尔表达式[,msg] 解释:assert是检验一个表达式是否为真.若不为真,则触发一个错误. 例如: assert False assert 1==2 as ...
- centos svn 升级
在服务器的/etc/yum.repos.d/下新建个文件夹,wandisco-svn.repo [WandiscoSVN]name=Wandisco SVN Repobaseurl=http://op ...
- MongoDB学习笔记五:聚合
『count』count是最简单的聚合工具,返回集合中的文档数量:> db.foo.count()0> db.foo.insert({"x" : 1})> db. ...
- Back-propagation, an introduction
About Contact Subscribe Back-propagation, an introduction Sanjeev Arora and Tengyu Ma • Dec 20, ...