$User = "xxx@junson.com" #把xxx@junson.com改成管理员账号
$PWord = ConvertTo-SecureString -String "password@123" -AsPlainText -Force #把password@123改成管理员密码
$UserCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
Connect-ExchangeOnline -Credential $UserCredential -ExchangeEnvironmentName O365China
$userdata=Import-Csv C:\Users\Junson\Desktop\userdata.csv -Encoding Default #把路径改成要导入的成员邮箱csv文件路径
Foreach($user in $userdata){
Add-DistributionGroupMember -Identity "测试通讯组" -Member $user.mailbox #把测试通讯组改成需要导入的Exchange通讯组名称;.mailbox是指所引用的csv文件列名
$User
}
userdata.csv文件格式参考如下
先决条件:
需要一台安装好.NET Framework 4.0和ExchangeOnlineManagement模块的Windows电脑
ExchangeOnlineManagement模块安装方法如下:
以管理员方式打开powershell,运行以下命令:
Install-Module -Name ExchangeOnlineManagement