zoukankan      html  css  js  c++  java
  • 用powershell批量新增user profile

     SharePoint 2013 新系统,要在User Profile Service里把人全加一下,其实同步ad更方便,但ad里的人太多,没必要全要,只要大中华区就行了,问hr要了一份人员名单,写了个脚本

    先来个xml,把要加的人ad账号列一下

    <Users>
      <UserName Name="user_a" />
      <UserName Name="user_b" />
      <UserName Name="user_c" />
      <UserName Name="user_d" />
      <UserName Name="user_e" />
      <UserName Name="user_f" />

    </Users>

    再来一段简单的脚本

    #********************************************************************
    # Create New User
    #
    #********************************************************************

    $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:\test.xml"

    Write-host ""
    Write-host -f Yellow "Starting create new user"

    # create a connection to the User Profile Manager
    $MySite = Get-SPSite <siteUrl>
    $context = Get-SPServiceContext $MySite

    # Get UserProfileManager Object
    $profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)

    $xmlData.Users.UserName | ForEach-Object {

      if($profileManager.UserExists($_.Name) -eq $false){
        $profileManager.CreateUserProfile($_.Name)
        Write-host -f Green $_.Name "created"
      }

      else{
        Write-host -f Red $_.Name "already exist"
      }

    }

  • 相关阅读:
    oracle参数文件(1)
    提高HTML5 canvas性能的几种方法(转)
    基于TouchVG开发的Windows矢量图形编辑器
    使用rapidjson实现了TouchVG的序列化适配器类
    关于用例的几个问题分析
    重温《UML风格》
    API设计准则(转)
    UML初级培训录音内容
    暂定的UML培训大纲
    基于Android平台多个Icon的APk——实现多程序入口总结(转)
  • 原文地址:https://www.cnblogs.com/graccc/p/3779587.html
Copyright © 2011-2022 走看看