メインコンテンツにスキップ

PowerShell を使用して移行できないメールボックス フォルダーを特定する

注: PowerShellとの連携には、ShareGate MigrateのProまたはEnterpriseサブスクリプションが必要です。Essentialsプランでは利用できません。

このスクリプトは、ShareGate Migrate がコピーしない2種類のメールボックス フォルダーを特定します。

  • 検出されない: ShareGate Migrate が認識できない、標準的でないコンテナー クラス(IPF.ImapIPF.SkypeTeams.Message など)を持つフォルダーです。これらのフォルダーは移行レポートに表示されません。

  • 設計上スキップされる: ShareGate Migrate が検出はするもののコピーしない、既知のシステム フォルダーです。ConversationHistoryClutterSyncIssuesConflictsLocalFailuresServerFailuresRecoverableItemsDeletionsSearchFoldersが該当します。これらも移行レポートには表示されません。

移行の前後に Get-NonMigratableMailboxFolders.ps1 を実行すると、両方の種類のフォルダーを特定し、カバレッジの不足を確認できます。

前提条件

  • Windows PowerShell(最適な結果を得るには、コマンド プロンプトの使用をお勧めします)

  • Exchange Online 権限によるソース メールボックスへのアクセス

スクリプトを実行する

以下のスクリプトをコピーして Get-NonMigratableMailboxFolders.ps1 として保存し、コマンド プロンプトから実行します。

param(
# Change this to the mailbox you want to scan
[Parameter(Mandatory = $true)]
[string]$Mailbox,

# Optional: provide a file path to also export the results as a CSV
[Parameter(Mandatory = $false)]
[string]$CsvOutputPath
)

$ErrorActionPreference = 'Stop'

$ModuleName = "ExchangeOnlineManagement"
$RequiredVersion = "3.9.0"

$module = Get-Module -ListAvailable -Name $ModuleName | Where-Object { $_.Version -eq [Version]$RequiredVersion }

if (-not $module) {
Install-Module -Name $ModuleName -RequiredVersion $RequiredVersion -Scope CurrentUser -Force
}

Import-Module -Name $ModuleName -RequiredVersion $RequiredVersion -Force

Connect-ExchangeOnline -ShowBanner:$false

try {
Write-Host "Scanning mailbox: $Mailbox" -ForegroundColor Cyan

$folders = Get-MailboxFolderStatistics -Identity $Mailbox |
Select-Object Name, FolderPath, FolderType, ContainerClass

$nonDetectable = @($folders | Where-Object {
$class = $_.ContainerClass
-not (
[string]::IsNullOrEmpty($class) -or
$class -eq 'IPF.Note' -or $class -like 'IPF.Note.*' -or
$class -eq 'IPF.Appointment' -or $class -like 'IPF.Appointment.*' -or
$class -eq 'IPF.Contact' -or $class -like 'IPF.Contact.*' -or
$class -eq 'IPF.Task' -or $class -like 'IPF.Task.*'
)
})

$skippedFolderTypes = @(
'ConversationHistory',
'Clutter',
'SyncIssues',
'Conflicts',
'LocalFailures',
'ServerFailures',
'RecoverableItemsDeletions',
'SearchFolders'
)
$skippedByDesign = @($folders | Where-Object { $skippedFolderTypes -contains $_.FolderType })

if ($nonDetectable.Count -eq 0) {
Write-Host "No non-detectable folders found." -ForegroundColor Green
}
else {
Write-Host "`nFolders that will NOT be detected by ShareGate ($($nonDetectable.Count) found):" -ForegroundColor Yellow
$nonDetectable | Format-Table Name, FolderPath, FolderType, ContainerClass -AutoSize
}

if ($skippedByDesign.Count -eq 0) {
Write-Host "No folders skipped by design found." -ForegroundColor Green
}
else {
Write-Host "`nFolders that ShareGate detects but skips by design ($($skippedByDesign.Count) found):" -ForegroundColor Yellow
$skippedByDesign | Format-Table Name, FolderPath, FolderType, ContainerClass -AutoSize
}

if ($CsvOutputPath) {
$report = @()
$report += $nonDetectable | Select-Object @{ Name = 'Reason'; Expression = { 'NotDetected' } }, Name, FolderPath, FolderType, ContainerClass
$report += $skippedByDesign | Select-Object @{ Name = 'Reason'; Expression = { 'SkippedByDesign' } }, Name, FolderPath, FolderType, ContainerClass
$report | Export-Csv -LiteralPath $CsvOutputPath -NoTypeInformation -Encoding UTF8
Write-Host "Report exported to: $CsvOutputPath" -ForegroundColor Green
}
}
finally {
Disconnect-ExchangeOnline -Confirm:$false
}

結果をコンソールに出力する場合:

.\Get-NonMigratableMailboxFolders.ps1 -Mailbox "[email protected]"

結果を CSV ファイルにエクスポートする場合:

.\Get-NonMigratableMailboxFolders.ps1 -Mailbox "[email protected]" -CsvOutputPath "C:\Reports\non-migratable-folders.csv"

エクスポートされたファイルには、各フォルダーについて Reason 列があり、値は NotDetected または SkippedByDesign のいずれかです。

トラブルシューティング

モジュールのインストール エラー

スクリプトが ExchangeOnlineManagement モジュールをインストールしようとした際にエラーが表示される場合は、スクリプトをテキスト エディターで開き、Install-Module の行に -AllowClobber を追加してください。

Install-Module -Name $ModuleName -RequiredVersion $RequiredVersion -Scope CurrentUser -Force -AllowClobber

この記事はAIによって翻訳されています。ご不明な点がある場合は、英語の原文をご確認ください。

こちらの回答で解決しましたか?