powershell 从XML输入管理用户配置文件的属性顺序(列出它们并重新排序)。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 从XML输入管理用户配置文件的属性顺序(列出它们并重新排序)。相关的知识,希望对你有一定的参考价值。
<Configuration>
<Properties>
<Property Name="RBLAProjets" Order="5207" />
<Property Name="RBLAProduits" Order="5208" />
<Property Name="RBLAExpertise" Order="5209" />
<Property Name="RBLARM" Order="5210" />
</Properties>
</Configuration>
# ----------------------------------------------
# Author: Radu Tut / Romain Blanchard
# Date: 11.02.2015
# Description: Manage User Profile's properties order (list and reorder), from XML input.
# ----------------------------------------------
# Import assemblies
Add-PSSnapin Microsoft.Sharepoint.Powershell -ErrorAction SilentlyContinue
Add-Type -Path "C:\program files\common files\microsoft shared\web server extensions\15\isapi\Microsoft.Office.Server.dll"
## Functions ##
# List all User Profile's properties.
# Input parameter are MySite's url and Profile Sub-Type name
function ListUPPDisplayOrder($mysiteUrl){
$mysite = Get-SPSite $mysiteUrl
$context = Get-SPServiceContext $mysite
$upcManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context)
$defaultUserProfileSubTypeName = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName("User")
$upcManager.ProfilePropertyManager.GetProfileSubtypeProperties($defaultUserProfileSubTypeName) | Format-Table -Property Name,DisplayName,DisplayOrder
}
# Reorder User Profile properties.
# Input parameters are XML configuration file path, MySite's url and Profile Sub-Type name
function UPPReorder($configFile, $mysiteUrl, $ProfileSubTypeName)
{
$config = [xml] (Get-Content $configFile)
$mys = Get-SPSite $mysiteUrl
$context = Get-SPServiceContext $mys
$upcManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context)
$defaultUserProfileSubTypeName = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName("User")
$profileSubtypePropManager = $upcManager.ProfilePropertyManager.GetProfileSubtypeProperties($defaultUserProfileSubTypeName)
# Reorder properties
foreach($property in $config.Configuration.Properties.childnodes)
{
$propName = $property.Name
Write-Host "Updating property $propName ..."
$profileSubtypePropManager.SetDisplayOrderByPropertyName($property.Name,$property.Order)
}
$profileSubtypePropManager.CommitDisplayOrder()
Write-Host "Finished."
}
## Utilization ##
#ListUPPDisplayOrder "http://rbla-sp2010-002/sites/mysite"
#UPPReorder "config.xml" "http://rbla-sp2010-002/sites/mysite"
以上是关于powershell 从XML输入管理用户配置文件的属性顺序(列出它们并重新排序)。的主要内容,如果未能解决你的问题,请参考以下文章
powershell netsh 导入 xml 配置文件
powershell 从XML文件创建和配置站点(创建主页,库,添加webpart,创建组...)。
添加位于多级的 XML 内容 - PowerShell 函数
从Powershell中的文本文件中输入值
powershell 从XML文件导入设置
PowerShell 从管理选项卡更改打印机配置