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

[玩转系统] 使用 PowerShell 查看和导出有关邮箱迁移到 Office 365 的信息 |第 3 部分#5

作者:精品下载站 日期:2024-12-14 09:06:50 浏览:16 分类:玩电脑

使用 PowerShell 查看和导出有关邮箱迁移到 Office 365 的信息 |第 3 部分#5


在当前文章和下一篇文章中,我们将回顾可用于查看和导出有关 Exchange 邮箱迁移过程的信息的各种 PowerShell cmdlet。
我们在本文中回顾的“邮箱迁移”PowerShell 命令是:

  • 获取迁移批处理
  • 获取移动请求
  • Get-MoveRequestStatistics

1、迁移批次|获取迁移批处理

术语“迁移批次”定义充当“逻辑容器”的实体,其中包含我们从源 Exchange 服务器迁移到目标 Exchange 的邮箱(及其关联用户)服务器(在我们的场景中为 Exchange Online)。

获取有关特定迁移批次的信息

PowerShell命令语法:

Get-MigrationBatch -Identity <Migration BATCH name>

PowerShell 控制台输出示例:

PS C:\> Get-MigrationBatch "Eyal Migration batch -001" |fl 

RunspaceId : 2771b392-d73b-4639-b63d-f4646c49c0af
Identity : Eyal Migration batch -001
Status : Completed
State : Completed
Flags : None
WorkflowStage : Processing
TriggeredAction : None
BatchGuid : fb2529fe-b9bf-446a-accd-3819e6bef03c
TotalCount : 2
ActiveCount : 0
StoppedCount : 0
SyncedCount : 0
FinalizedCount : 2
FailedCount : 0
FailedInitialSyncCount : 0
FailedIncrementalSyncCount : 0
CompletedWithWarningCount : 0
PendingCount : 0
ProvisionedCount : 0
ValidationWarningCount : 0
ValidationWarnings : {}
Message : 
CreationDateTime : 2/23/2017 10:41:09 AM
CreationDateTimeUTC : 2/23/2017 8:41:09 AM
StartDateTime : 2/23/2017 10:41:09 AM
StartDateTimeUTC : 2/23/2017 8:41:09 AM
InitialSyncDateTime : 
InitialSyncDateTimeUTC : 
InitialSyncDuration : 
LastSyncedDateTime : 2/23/2017 10:47:28 AM
LastSyncedDateTimeUTC : 2/23/2017 8:47:28 AM
FinalizedDateTime : 
FinalizedDateTimeUTC : 
SubmittedByUser : [email protected]
OwnerId : EURPR05A001.prod.outlook.com/Microsoft Exchange Hosted Organizations/o365info2.onmicrosoft.com/Eyal
OwnerExchangeObjectId : 7646f17d-bf1f-4e07-8698-4e71ab4dad80
NotificationEmails : {[email protected]}
ExcludedFolders : {}
MigrationType : ExchangeRemoteMove
BatchDirection : Onboarding
Locale : en-US
Reports : {When migration report was created:2/23/2017 9:19:17 AM; Migration report URL:https://outlook.office365.com/ecp/Migration/DownloadReport.aspx?HandlerClass=
 MigrationReportHandler&Name=MigrationReport.csv&DelegatedOrg=o365info2.onmicrosoft.com&realm=o365info2.onmicrosoft.com&exsvurl=1&Identity=RgAAAAAKqOiME1CMQ
 LkjirbMEluxBwCuLv0wEUQXTp3grhMeQsz8AAAh0Mi_AACuLv0wEUQXTp3grhMeQsz8AAN-JngxAAAJ; Error report URL:}
IsProvisioning : False
BatchFlags : ReportInitial
WorkflowControlFlags : None
AutoRetryCount : 0
CurrentRetryCount : 0
AllowUnknownColumnsInCsv : False
DiagnosticInfo : 
SupportedActions : Remove
SourceEndpoint : mail.o365info.com
TargetEndpoint : 
SourcePublicFolderDatabase : 
TargetDatabases : {}
TargetArchiveDatabases : {}
TargetDAGs : {}
BadItemLimit : 10
LargeItemLimit : 0
MoveOptions : {}
SkipMoving : {}
SkipMerging : {}
InternalFlags : {}
PrimaryOnly : False
ArchiveOnly : False
TargetDeliveryDomain : o365info2.mail.onmicrosoft.com
SkipSteps : None
Workflow : Steps: [(Injection), (Processing)]
WorkflowTemplate : 
Report : 
StartAfter : 
StartAfterUTC : 
CompleteAfter : 
CompleteAfterUTC : 
IsValid : True
ObjectState : Unchanged

导出有关特定迁移批次的详细信息 | TXT文件

Get-MigrationBatch -Identity migration-003 -IncludeReport -Diagnostic | Format-List | Out-File c:\temp\"Get-MigrationBatch-IncludeReport-Diagnostic.txt" -Encoding UTF8

导出有关所有迁移批次的详细信息

导出信息到TXT文件

Get-MigrationBatch -IncludeReport -Diagnostic | Format-List | Out-File c:\temp\"ALL Migration -Get-MigrationBatch-IncludeReport-Diagnostic.txt" -Encoding UTF8

将信息导出到 XML 文件

Get-MigrationBatch -IncludeReport -Diagnostic | Export-Clixml
c:\temp\"ALL Migration Get-MigrationBatch-IncludeReport-Diagnostic.xml" -Encoding UTF8

迁移批次状态

使用“Status”参数,我们可以获得有关具有特定“Status”的现有迁移批次的信息。

“Statuses”值的迁移批次类型可以如下:

  • 完全的
  • 已完成但有错误
  • 正在完成
  • 已损坏
  • 已创建
  • 失败的
  • 增量同步
  • 去除
  • 开始
  • 已停止
  • 正在同步
  • 停止
  • 已同步
  • 与错误同步
  • 等待

要查看具有特定状态的迁移批次,我们可以使用以下 PowerShell 语法。

显示状态为“已完成”的所有迁移批次

PowerShell 命令示例:

Get-MigrationBatch -Status Completed

PowerShell 控制台输出示例:

PS C:\> Get-MigrationBatch -Status Completed 

Identity                   Status     Type                TotalCount
--------                   ------     ----                ----------
Eyal Migration batch -001  Completed  ExchangeRemoteMove  2 
Eyal Migration batch -002  Completed  ExchangeRemoteMove  2

导出状态为“未完成”的所有迁移批次的信息 | TXT文件

PowerShell 命令示例:

Get-MigrationBatch | Where {$_.status -ne ”Completed”} | Get-MoveRequestStatistics | Format-List | Out-File c:\temp\"Get-MigrationBatch Not Completed.txt" -Encoding UTF8

3. 移动请求

术语“移动请求”定义了我们从“源 Exchange 服务器”迁移到“目标 Exchange 服务器”的 Exchange 邮箱

我们用于获取有关“邮箱实体”的移动请求信息的两个 PowerShell cmdlet 是:

  • 获取移动请求
  • 获取移动请求统计

2. 使用 Get-MoveRequest 命令

PowerShell 命令Get-MoveRequest,获取有关我们迁移的特定邮箱的属性的基本信息。

获取有关特定移动请求的信息

PowerShell 命令语法

Get-MoveRequest < Move Request name>

PowerShell 控制台输出示例

PS C:\> Get-MoveRequest [email protected] | Format-List

RunspaceId : 2771b392-d73b-4639-b63d-f4646c49c0af
ExchangeGuid : e3254cfe-81c0-496e-84db-80e9190342e5
SourceDatabase : 
TargetDatabase : EURPR05DG136-db018
SourceArchiveDatabase : 
TargetArchiveDatabase : 
Flags : CrossOrg, Pull
RemoteHostName : mail.o365info.com
BatchName : MigrationService:Eyal Migration batch -001
Status : Completed
RequestStyle : CrossOrg
Direction : Pull
IsOffline : False
Protect : False
Suspend : False
SuspendWhenReadyToComplete : False
AdministrativeUnits : {}
Alias : onpremmbx-01
ExtensionCustomAttribute1 : {}
ExtensionCustomAttribute2 : {}
ExtensionCustomAttribute3 : {}
ExtensionCustomAttribute4 : {}
ExtensionCustomAttribute5 : {}
DisplayName : onpremmbx-01
ExternalDirectoryObjectId : c4d8af0e-69f2-4534-b79c-04ddaea7d074
LastExchangeChangedTime : 
RecipientType : UserMailbox
RecipientTypeDetails : UserMailbox
Identity : onpremmbx-01
IsValid : True
ExchangeVersion : 0.20 (15.0.0.0)
Name : onpremmbx-01
DistinguishedName : CN=onpremmbx-01,OU=o365info2.onmicrosoft.com,OU=Microsoft Exchange Hosted Organizations,DC=EURPR05A001,DC=prod,DC=outlook,DC=com
Guid : 1e697c91-3a05-490d-a1d2-4434471cd1d9
OrganizationId : EURPR05A001.prod.outlook.com/Microsoft Exchange Hosted Organizations/o365info2.onmicrosoft.com - EURPR05A001.prod.outlook.com/ConfigurationUnits/o365info2.onmicrosoft.com/Configuration
Id : onpremmbx-01
OriginatingServer : DB3PR05A001DC03.EURPR05A001.prod.outlook.com
ObjectState : Changed

导出有关特定移动请求的信息 | TXT文件

Get-MoveRequest [email protected] | Format-List | Out-File c:\temp\"Get-MoveRequest.txt" -Encoding UTF8

获取有关所有现有移动邮箱请求的信息

当我们使用 PowerShell 时,命令 Get-MoveRequest 与特定移动请求无关,这意味着,在不指定特定移动请求身份的情况下,PowerShell 命令将显示有关所有现有“移动请求”的信息。

注意:如果您执行的邮箱迁移包括数十个或数百个邮箱,则导出有关每个已迁移邮箱的信息的过程可能需要很长时间。

导出有关所有移动请求的信息 | TXT文件

PowerShell 命令示例

Get-MoveRequest | Format-List | Out-File c:\temp\"Get-MoveRequest.txt" -Encoding UTF8

导出有关具有特定状态的 MoveRequest 的信息

每个“移动请求”都可以有一个特定的“状态”,例如已完成失败等。

可用的状态代码值如下:

  • 自动暂停
  • 完全的
  • 已完成但有警告
  • 完成中
  • 失败的
  • 进行中
  • 没有任何
  • 排队

如果您只想获取有关“移动请求”特定状态的信息,可以使用以下 PowerShell 语法。

导出有关状态未“已完成”的所有移动请求的信息 | TXT文件

Get-MoveRequest | Where {$_.status -ne ”Completed”} | Get-MoveRequestStatistics | Format-List | Out-File c:\temp\"Get-MoveRequest- status is not completed.txt" -Encoding UTF8

导出有关状态为“失败”的所有移动请求的信息 | TXT文件

PowerShell 命令示例:

Get-MoveRequest | Where {$_.status -eq ”Failed”} | Get-MoveRequestStatistics | Format-List | Out-File c:\temp\"Get-MoveRequest- status is Failed.txt" -Encoding UTF8

3. 使用 MoveRequestStatistics 命令

PowerShell 命令 Get-MoveRequestStatistics 的目的是获取有关“迁移的邮箱内容”的详细信息。

例如:

  • ItemsTransferred:有关已传输的邮件数量的信息。
  • 完成百分比:顾名思义,有关邮箱迁移过程的“完成百分比”的信息。

获取移动请求 特定移动请求的统计信息

PowerShell 命令语法

Get-MoveRequestStatistics <Migrated mailbox>

PowerShell 控制台输出示例

PS C:\> Get-MoveRequestStatistics [email protected]

DisplayName   StatusDetail  TotalMailboxSize  TotalArchiveSize  PercentComplete
-----------   ------------  ----------------  ----------------  ---------------
onpremmbx-01  Completed     7.148 MB          (7,495,583 bytes) 100

导出有关特定移动请求的信息TXT文件

Get-MoveRequestStatistics [email protected] | Format-List | Out-File c:\temp\"Get-MoveRequestStatistics.txt" -Encoding UTF8

如果我们想消除不必要的数据并获得邮箱迁移统计信息的“清晰视图”,我们可以要求PowerShell仅显示特定的数据字段。

PowerShell 命令示例:

Get-MoveRequestStatistics [email protected] | Select MailboxIdentity,Status,WorkloadType,RecipientTypeDetails,SourceServer ,BatchName,TotalMailboxSize,TotalMailboxItemCount,TotalArchiveSize,BytesTransferred,BytesTransferredPerMinute,ItemsTransferred,PercentComplete | Format-List | Out-File c:\temp\"Get-MoveRequestStatistics.txt" -Encoding UTF8

组合 Get-MoveRequest + Get-Moverequeststatistics 命令

使用 PowerShell 时我们可以使用的一个不错的选项是两个或多个 PowerShell 命令的“组合”。此方法的正式术语是“管道”。

在以下场景中,我们组合使用两个 PowerShell 命令:

  • 获取移动请求
  • Get-MoveRequestStatistics

第一个命令Get-MoveRequest将“获取”所有现有的“移动请求”。

第二个命令Get-MoveRequestStatistics,将使用第一个命令中的“移动请求列表”,并为每个邮箱移动请求添加“统计信息”。

组合 Get-MoveRequest + Get-Moverequeststatistics 命令

PowerShell命令语法:

Get-MoveRequest| Get-Moverequeststatistics

PowerShell 控制台输出示例:

PS C:\> Get-MoveRequest| Get-Moverequeststatistics 

DisplayName   StatusDetail  TotalMailboxSize  TotalArchiveSize  PercentComplete
-----------   ------------  ----------------  ----------------  ---------------
onpremmbx-02  Completed     7.148 MB          (7,495,429 bytes) 100 
onpremmbx-03  Completed     7.148 MB          (7,495,563 bytes) 100 
onpremmbx-04  Completed     7.148 MB          (7,495,449 bytes) 100 
onpremmbx-01  Completed     7.148 MB          (7,495,583 bytes) 100

获取+导出有关所有并发移动请求的信息统计+故障排除信息

在此场景中,我们添加附加参数 -IncludeReport 和 -Diagnostic 以获取有关移动请求统计信息的更多详细信息。大多数时候,我们会在故障排除场景中使用这个附加参数。

另外,我添加了一个将信息导出到 XML 文件的示例,因为如果我们需要将导出的信息传递给 Microsoft 支持人员进行进一步分析,这是“首选”文件格式。

组合 Get-MoveRequest + Get-Moverequeststatistics 命令

导出信息到TXT文件

Get-MoveRequest| Get-Moverequeststatistics -IncludeReport -Diagnostic | Format-List | Out-File c:\temp\"Get-Move-Request-Get-Moverequeststatistics.txt" -Encoding UTF8

将信息导出到 CSV 文件

Get-MoveRequest| Get-Moverequeststatistics -IncludeReport -Diagnostic | Export-CSV c:\temp\"Get-Move-Request-Get-Moverequeststatistics.CSV" -NoTypeInformation -Encoding utf8

将信息导出到 XML 文件

Get-MoveRequest| Get-Moverequeststatistics -IncludeReport -Diagnostic | Export-Clixml
c:\temp\"Get-MoveRequestStatistics-IncludeReport-Diagnostic.xml" -Encoding UTF8

我们可以使用 PowerShell 命令语法的其他变体来获取有关具有特定状态的移动请求的信息,例如失败的移动请求+有关每个移动请求的统计信息。

PowerShell 命令示例:

Get-MoveRequest -movestatus Failed| Get-moverequeststatistics |select DisplayName,SyncStage,Failure*,Message,PercentComplete,largeitemsencountered,baditemsencountered| ft -autosize

下载邮件迁移 PowerShell 脚本

当前文章系列的下一篇文章

使用 PowerShell 查看和导出有关邮箱迁移到 Office 365 的信息 |第 4 部分#5

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

取消回复欢迎 发表评论:

关灯