【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 ...
随机推荐
- ulua 路径小记 以及 lua require 机制整理
ulua 路径小记 在学习ulua时,require模块的根路径可以为项目的Lua文件夹或者ToLua文件夹(Editor下),但是在package.path和package.cpath中并没有看到当 ...
- android之animation
Android Animation一共有四种 Alpha: 淡入淡出效果 Scale: 缩放效果 Rotate: 旋转效果 Translate:移动效果 使用Tweened Animations的步 ...
- 编译c
1.打开vs工具 2.弄到相同路径(同所编译文件) 3.cl(微软编译器) 生成 obj exe文件 4.system是一个通用指令 可以在windows linux mac用
- Android 中算法问题
1:冒泡排序: 冒泡排序的思路: 相邻的两个数进行比较 (1):首先需要连个for 循环 (2):最外层for 循环控制最里面 for 循环的循环次数 (3):通过设置中间参数的方式进行交换 (4): ...
- WaitForMultipleObjects返回失败原因之一
上网搜了下 关于 WaitForMultipleObjects等待多个线程退出的状态失败的情况,也有人遇到类似的情况. 一次项目中我也遇到这么个情况.项目中创建线程都是用的 _beginthread ...
- iOS初步开发
趁公司目前iOS整个没人管理,我折腾一下调试工具,刚好nordic也有参考demo. 然后作为helloworld级别的我... 就直接down下来,结果,还不错, 不像oschina.net和cod ...
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
以前一直用的VC6.0,最近换成VS2010了.哎这几天光折腾VS2010了. 曾经我以为程序没啥头绪忒头疼,现在觉得乱七八糟的编译问题才叫一个头裂=口= 原因:VC6.0中,如果没有直接显示指定的返 ...
- Python之路,day6-Python基础
1.config 模块 import configparser conf = configparser.ConfigParser() conf[', 'Compression': 'yes', '} ...
- SQL Server 连接字符串备忘
今天把服务器上的远程访问关了,把连接字符串中的IP地址改成了.,然后就一直连不上.弄了半天,原来是本地连接时非默认实例,不能带端口号. 1.原来的连接服务器地址是:192.168.0.1SQL2005 ...
- POSIX正则表达式
POSIX正则表达式规范 参考:http://en.wikipedia.org/wiki/Regular_expression POSIX正则表达式分为Basic Regular Expression ...