首页 > 其他 > 详细

用powershell批量新增user profile

时间:2014-06-10 17:11:10      阅读:345      评论:0      收藏:0      [点我收藏+]

 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"
  }

}

用powershell批量新增user profile,布布扣,bubuko.com

用powershell批量新增user profile

原文:http://www.cnblogs.com/graccc/p/3779587.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!