全球主机交流论坛
标题:
Office365微软邮局批量添加别名
[打印本页]
作者:
ismile
时间:
2023-12-16 00:09
标题:
Office365微软邮局批量添加别名
本帖最后由 ismile 于 2023-12-16 00:08 编辑
官方文档地址
https://learn.microsoft.com/zh-cn/exchange/recipients-in-exchange-online/manage-user-mailboxes/add-or-remove-email-addresses
1.安装 Exchange Online PowerShell 模块
Win+X管理员运行PowerShell,执行命令
Install-Module -Name ExchangeOnlineManagement -Force -AllowClobber
复制代码
2.连接到Exchange Online PowerShell:
Connect-ExchangeOnline
复制代码
3.获取所有用户邮箱
$users = Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName, UserPrincipalName
复制代码
4.截取UserPrincipalName中@前的字符拼接需要添加别名邮箱的域名
foreach ($user in $users) {
$newEmailAddress = ($user.UserPrincipalName -split "@")[0] + "@aaaaa.com"
Set-Mailbox -Identity $user.UserPrincipalName -EmailAddresses @{add=$newEmailAddress}
}
复制代码
5.运行完成。
有错误的会报错并跳过
欢迎光临 全球主机交流论坛 (https://loc.xiu.ee/)
Powered by Discuz! X3.4