码迷,mamicode.com
首页 > 系统相关 > 详细

【转载】Powershell在世纪互联Office365中批量将用户添加到组

时间:2014-10-21 10:12:50      阅读:263      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   ar   for   sp   

 1 $NewUserPath = ".\Office365AddUserToGroup.csv"
 2 
 3 $NewUsers = import-csv $NewUserPath
 4 
 5 foreach ($NewUser in $NewUsers) {
 6 $Mail=$NewUser.Mail
 7 $Mail
 8 $Groups=$NewUser.Group
 9 $Groups
10 
11 $Groups.split(";") | ForEach {
12 $Group=$_
13 $Group
14 Add-DistributionGroupMember $Group -Member $Mail -BypassSecurityGroupManagerCheck
15 }
16 echo =======================================================
17 }
18 
19 get-pssession | remove-pssession
20 
21 Stop-Transcript

CSV格式:
Mail,Group
user1@contoso.com,all@contoso.com;hr@contoso.com
user2@contoso.com,all@contoso.com
user3@contoso.com,it@contoso.com;tech@contoso.com;admin@contoso.com

 

http://www.smallrascal.cn/smallrascal/article.asp?id=2084  

【转载】Powershell在世纪互联Office365中批量将用户添加到组

标签:style   blog   http   color   io   os   ar   for   sp   

原文地址:http://www.cnblogs.com/SignalTips/p/4026770.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!