当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 使用 PowerShell 将邮箱移动到 Exchange Online

作者:精品下载站 日期:2024-12-14 03:15:47 浏览:14 分类:玩电脑

使用 PowerShell 将邮箱移动到 Exchange Online


安装混合配置向导 (HCW) 后,您希望使用 PowerShell 将邮箱移动到 Exchange Online。该术语也称为将邮箱载入云。那么需要在PowerShell中填写什么来开始邮箱迁移呢?在本文中,您将了解如何使用 PowerShell 将邮箱迁移到 Exchange Online。

如何使用 PowerShell 将邮箱移动到 Exchange Online

要使用 PowerShell 将邮箱移动到 Exchange Online,请执行以下步骤:

1. 连接到 Exchange Online PowerShell

以管理员身份启动 PowerShell 并连接到 Exchange Online PowerShell。

Connect-ExchangeOnline

注意:您不会将本地邮箱推送到 Exchange Online。事实上,您正在从 Exchange Online 中提取本地邮箱。这就是为什么您需要连接到 Exchange Online 并从 Exchange Online PowerShell 运行命令。

2.查找迁移端点远程服务器URL

使用 Get-MigrationEndpoint cmdlet 获取远程服务器 URL。详细了解如何查找用于邮箱迁移的 RemoteHostName URL。混合配置向导创建了此迁移端点。

Get-MigrationEndpoint | Format-List Identity, RemoteServer

将出现以下输出。根据需要在下一部分中复制 RemoteServer URL 值。

Identity     : Hybrid Migration Endpoint - EWS (Default Web Site)
RemoteServer : mail.exoip.com

3. 使用 PowerShell 将邮箱移动到 Exchange Online

创建新的移动请求以将主邮箱和存档邮箱移动到 Exchange Online。填写以下详细信息:

  • -身份:邮箱名称或电子邮件地址
  • -RemoteHostName:您在上一步中复制的远程服务器
  • -TargetDeliveryDomain: 用于 Exchange Online 组织邮箱的主 SMTP 域
  • -RemoteCredential:具有权限的本地管理员帐户

运行命令后,将显示凭据登录请求。填写本地凭据 (RemoteCredential) 的密码。

New-MoveRequest -Identity "Maisha.Lee@exoip.com" -Remote -RemoteHostName "mail.exoip.com" -TargetDeliveryDomain "exoip365.mail.onmicrosoft.com" -RemoteCredential (Get-Credential)

4. 使用 PowerShell 将多个邮箱移动到 Exchange Online

创建一个名为 Users.csv 的 CSV 文件,并将其放置在目录 C:\migration 中。

打开 CSV 文件,将标题列命名为 EmailAddress,然后填写您想要移动到 Exchange Online 的所有邮箱。

[玩转系统] 使用 PowerShell 将邮箱移动到 Exchange Online

复制下面的脚本并更改前 3 行。之后,运行脚本。

$Mailboxes = Import-Csv "C:\Migration\Users.csv"
$RemoteHostName = "mail.exoip.com"
$TargetDeliveryDomain = "exoip365.mail.onmicrosoft.com"
$OnPremCred = (Get-Credential)

# Move mailboxes in CSV file to Exchange Online
foreach ($Mailbox in $Mailboxes) {
    $params = @{
        Identity             = $mailbox.EmailAddress
        Remote               = $true
        RemoteHostName       = $RemoteHostName
        TargetDeliveryDomain = $TargetDeliveryDomain
        RemoteCredential     = $OnPremCred
    }

    New-MoveRequest @params
}

5. 使用 PowerShell 仅将主邮箱移动到 Exchange Online

假设存档邮箱位置位于 Exchange Online 中,主邮箱位置位于 Exchange 本地。当您运行上述命令时,您会收到以下错误消息:

您必须指定 PrimaryOnly 参数
目标用户“Maisha Lee”已有存档邮箱。

这是它在 PowerShell 控制台中的外观:

PS C:\> New-MoveRequest -Identity "Maisha.Lee@exoip.com" -Remote -RemoteHostName "mail.exoip.com" -TargetDeliveryDomain "exoip365.mail.onmicrosoft.com" -RemoteCredential (Get-Credential)
You must specify the PrimaryOnly parameter.
Target user 'Maisha Lee' already has an archive mailbox.
    + CategoryInfo          : NotSpecified: (:) [New-MoveRequest], MailboxReplicationPermanentException
    + FullyQualifiedErrorId : [Server=PAXP190MB1743,RequestId=3f8179c3-aa93-453f-9e14-d824968f34c4,TimeStamp=5/28/2022
    7:19:13 AM] [FailureCategory=Cmdlet-MailboxReplicationPermanentException] FE8B9422,Microsoft.Exchange.Management.
  Migration.MailboxReplication.MoveRequest.NewModernMoveRequest
    + PSComputerName        : outlook.office365.com

您必须将 -PrimaryOnly 参数添加到命令中。

创建新的移动请求以仅将主邮箱移动到 Exchange Online。填写以下详细信息:

  • -身份:邮箱名称或电子邮件地址
  • -RemoteHostName:您在上一步中复制的远程服务器
  • -PrimaryOnly: 将值保留为空
  • -TargetDeliveryDomain: 用于 Exchange Online 组织邮箱的主 SMTP 域
  • -RemoteCredential:具有权限的本地管理员帐户

运行命令后,将显示凭据登录请求。填写本地凭据 (RemoteCredential) 的密码。

New-MoveRequest -Identity "Maisha.Lee@exoip.com" -Remote -RemoteHostName "mail.exoip.com" -PrimaryOnly -TargetDeliveryDomain "exoip365.mail.onmicrosoft.com" -RemoteCredential (Get-Credential)

6. 使用 PowerShell 仅将存档邮箱移动到 Exchange Online

您必须将 -ArchiveOnly 参数添加到命令中。

创建新的移动请求以仅将存档邮箱移动到 Exchange Online。填写以下详细信息:

  • -身份:邮箱名称或电子邮件地址
  • -RemoteHostName:您在上一步中复制的远程服务器
  • -ArchiveOnly: 将值保留为空
  • -TargetDeliveryDomain: 用于 Exchange Online 组织邮箱的主 SMTP 域
  • -RemoteCredential:具有权限的本地管理员帐户

运行命令后,将显示凭据登录请求。填写本地凭据 (RemoteCredential) 的密码。

New-MoveRequest -Identity "Maisha.Lee@exoip.com" -Remote -RemoteHostName "mail.exoip.com" -ArchiveOnly -TargetDeliveryDomain "exoip365.mail.onmicrosoft.com" -RemoteCredential (Get-Credential)

7. 获取邮箱移动状态

使用 Get-MoveRequest cmdlet 获取邮箱移动请求的状态。

Get-MoveRequest -Identity "Maisha.Lee@exoip.com" | Get-MoveRequestStatistics

运行以下命令以获取所有邮箱移动请求。

Get-MoveRequest | Get-MoveRequestStatistics

输出显示邮箱移动状态并显示已完成状态。

DisplayName StatusDetail TotalMailboxSize            TotalArchiveSize PercentComplete
----------- ------------ ----------------            ---------------- ---------------
Maisha Lee  Completed    32.11 MB (33,670,771 bytes) 0 B (0 bytes)    100

如果情况并非如此并且您无法完成邮箱移动请求,您可以暂停并恢复移动请求。当您处于失败状态时,它在大多数情况下都会有所帮助。例如,状态详细信息TransientFailure

本文是否帮助您使用 PowerShell 将邮箱迁移到 Exchange Online?我希望它做到了。

了解更多:使用 PowerShell 完成迁移批处理 »

结论

您了解了如何使用 PowerShell 将邮箱移动到 Exchange Online。连接到 Exchange Online PowerShell 并运行本文中所示的命令。请记住监视邮箱移动到 Exchange Online 的过程,直到成功完成。

您喜欢这篇文章吗?您可能还喜欢目标邮箱没有匹配的 SMTP 代理。不要忘记关注我们并分享这篇文章。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯