zoukankan      html  css  js  c++  java
  • 根据XML更新Userprofile

    #  Using powershell code, update the user profile base on the XML file.
    #  Date: 2015-01-29


    # Update New User Property $snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'} if ($snapin -eq $null) { Write-Host "Loading SharePoint Powershell Snapin..." Add-PSSnapin "Microsoft.SharePoint.Powershell" Write-Host "SharePoint Powershell Snapin Loaded" } # Get XML Configuration file [xml]$xmlData=Get-Content "C:xxxxxxxx.xml" -Encoding UTF8 # Get Connection to MySite $MySite = Get-SPSite -Identity "http://xxxxxx" # Get Context $context = Get-SPServiceContext($MySite) # Get UserProfileManager Object $ProfileMngr = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) # Get All User Profiles #$profiles = $ProfileMngr.GetEnumerator() $xmlData.Users.UserName | ForEach-Object{ if ($ProfileMngr.UserExists($_.Name) -eq $false){ $ProfileMngr.CreateUserProfile($_.Name) } $userprofile = $ProfileMngr.GetUserProfile($_.Name) $userprofile["DP-JobNo"].value = $_.JobNo.Name $userprofile["PreferredName"].value = $_.PreferredName.Name $userprofile["DP-CompanyCode"].value = $_.CompanyCode.Name $userprofile["DP-Company"].value = $_.Company.Name $userprofile["DP-Department"].value = $_.Department.Name $userprofile["DP-ReportToLeader"].value = $_.ReportTo.Name $userprofile["DP-CostCentre"].value = $_.CostCentre.Name $userprofile.Commit() Write-Host -f Yellow $_.Name "Done" }
    <User Name="xxxx">
        <Chinese Name="xxx"/>
        <Title Name=""/>
        <CostCenter Name="xxx"/>
        <Report Name="xxxxx"/>
        <Company Name="xxxx"/>
        <Bank Name="xxxxxx"/>
        <Internal Name=""/>
        <Sap Name=""/>
        <IsSales Name="False"/>
        <IsService Name="False"/>
    </User>
  • 相关阅读:
    R语言数据集合
    转:EXCEL中如何获取从某一字符开始到最右边字符串
    转:EXCEL打乱顺序
    转:excel中怎样做柱状图
    转:linux复制/剪切文件到另一个文件夹
    转:Linux常用命令
    转:怎么在一张PPT里设置很多步骤出现的内容呀
    禅道分析
    转:BUG的严重级别分类 BUG状态标准
    转:Bug的严重等级和优先级
  • 原文地址:https://www.cnblogs.com/batter152/p/4244456.html
Copyright © 2011-2022 走看看