首页 > 代码库 > 【转载】Powershell在世纪互联Office365中批量将用户添加到组

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

 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 $Groups10 11 $Groups.split(";") | ForEach {12 $Group=$_13 $Group14 Add-DistributionGroupMember $Group -Member $Mail -BypassSecurityGroupManagerCheck15 }16 echo =======================================================17 }18 19 get-pssession | remove-pssession20 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中批量将用户添加到组