【问题标题】:Add SMTP Email Address and set as default, right after mailbox enabling as 365添加 SMTP 电子邮件地址并设置为默认值,邮箱启用为 365
【发布时间】:2022-01-11 15:30:15
【问题描述】:

连接到 Exchange 2016(本地)后,我有以下功能,运行良好:

$username = Read-Host -Prompt "`n Please provide AD-USERNAME to Migrate";

Enable-RemoteMailbox -Identity $username -RemoteRoutingAddress($username+'@MYORG.mail.onmicrosoft.com')

sleep 30

Get-RemoteMailbox $username|Set-RemoteMailbox -EmailAddressPolicyEnabled:$true

我现在需要做的是为每个使用该语法创建的邮箱设置一个新的 smtp 地址。

在不同的脚本中,我使用类似以下的内容来添加额外的 SMTP 并将它们设置为 邮箱的默认值:


    Set-RemoteMailbox $username -EmailAddresses @{add="$smtp"}
    Set-RemoteMailbox $username -EmailAddressPolicyEnabled $false -PrimarySmtpAddress "$smtp"

不确定,这会以同样的方式在这里工作,amyeb 更像是那种吗?

Get-RemoteMailbox $username| Set-RemoteMailbox $username -EmailAddresses @{add=$username+'@MYORG.com'}

嗯,我不确定从这里到哪里去用语法来做我需要的事情......希望得到一些帮助。

提前谢谢大家!

【问题讨论】:

    标签: powershell exchange-server


    【解决方案1】:

    由于您处于混合的本地和云交换环境中,并且您希望将新的电子邮件地址别名添加到现有的本地邮箱,以下是其完成方式。

    Set-RemoteMailbox cmdlet - 为 本地邮件用户 配置 Exchange 属性。本地邮件用户上设置的配置将同步到服务中与其关联的邮箱。

    Get-RemoteMailbox cmdlet 检索 本地 Active Directory邮件用户邮件相关属性强>。它不检索关联的基于云的邮箱的属性。本地邮件用户和关联的基于云的邮箱的大部分邮件相关属性应该相同。但是,基于云的邮箱具有您无法使用此 cmdlet 查看的其他属性。

    向现有邮箱添加新 SMTP 地址的示例脚本

    $users = ("user1", "user2")
    foreach ($user in $users) {
        $smtpdomain = "@MYORG.mail.onmicrosoft.com" # domain name
        $username = $user.ToString() # user name to string 
        $emailadd = $username + $smtpdomain # String the user's prefix and new suffix together
        $emailadd = $emailadd.ToString() # email address to string
        Get-RemoteMailbox $user | Set-RemoteMailbox -EmailAddresses @{add=$newSMTP} # add email address
    }
    
    

    使用 Exchange Online PowerShell 将电子邮件地址添加到多个邮箱 https://docs.microsoft.com/en-us/exchange/recipients-in-exchange-online/manage-user-mailboxes/add-or-remove-email-addresses

    包含用户名和电子邮件地址的 csv 文件

    列标题是 Mailbox 和 NewEmailAddress 分隔符是','

    Mailbox,NewEmailAddress
    Dan Jump,danj@northamerica.contoso.com
    David Pelton,davidp@northamerica.contoso.com
    Kim Akers,kima@northamerica.contoso.com
    Janet Schorr,janets@northamerica.contoso.com
    Jeffrey Zeng,jeffreyz@northamerica.contoso.com
    Spencer Low,spencerl@northamerica.contoso.com
    Toni Poe,tonip@northamerica.contoso.com
    

    运行以下命令,使用 CSV 文件中的数据将电子邮件地址添加到 CSV 文件中指定的每个邮箱。

    Import-CSV "C:\temp\AddEmailAddress.csv" | ForEach {Set-RemoteMailbox $_.Mailbox -EmailAddresses @{add=$_.NewEmailAddress}
    

    【讨论】:

      【解决方案2】:

      我们已通过将-PrimarySmtpAddress 添加到初始Enable-RemoteMailbox 字符串并删除EmailAddressPolicyEnabled:$true 在内部解决了该问题 一起来。

      $username = Read-Host -Prompt "`n Please provide AD-USERNAME to Migrate";
      
      Enable-RemoteMailbox -Identity $username -RemoteRoutingAddress($username+'@MYORG.mail.onmicrosoft.com') -PrimarySmtpAddress($username+'@MYORG.com')
      
      sleep 30
      
      ## Removed ## >> Get-RemoteMailbox $username|Set-RemoteMailbox -EmailAddressPolicyEnabled:$true
      

      感谢大家的努力。谢谢。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-12-22
        • 1970-01-01
        • 2021-08-04
        • 2023-03-18
        • 2014-04-30
        • 1970-01-01
        相关资源
        最近更新 更多