メモ: PowerShell 連携には、ShareGate Migrate の Pro または Enterprise サブスクリプションが必要です。Essentials プランでは利用できません。
PowerShell を使用して、CSV ファイルから ShareGate Migrate のユーザー マッピング ファイル(SGUM)を生成します。
SGUM ファイルは、Migrate アプリまたは PowerShell スクリプトで使用できます。
メモ: アプリケーションはユーザーを自動的にマッピングします。マッピング ファイルに追加しなかったユーザーは、ShareGate Migrate が自動でマッピングします。
前提条件
ユーザー情報、または Active Directory/Microsoft Entra ID へのアクセス権。
CSV を作成する
CSV は手動で作成することも、Active Directory からユーザーの一覧を取得することもできます。最終的な CSV ファイルには、SourceValue と DestinationValue の 2 つの列が必要です。値にはメール アドレス、ユーザー名、表示名、フル ネームのいずれかを使用できます。
Excel では、ファイルは次のようになります。
ヒント: メール アドレスの使用をお勧めします。通常、メール アドレスは一意でドメインも含まれます。
スクリプトを作成する
次のスクリプトを、任意の PowerShell アプリケーションにコピーして貼り付けます。
# Import the ShareGate module
Import-Module Sharegate
# Define the path to the CSV file containing user and group mappings
$csvFile = "C:\CSVfile.csv"
# Import the CSV file into a table variable, specifying the delimiter as a comma
$table = Import-CSV $csvFile -Delimiter ","
# Create a new mapping settings object to store user and group mappings
$mappingSettings = New-MappingSettings
# Loop through each row in the imported CSV table
foreach ($row in $table) {
# Set user and group mappings for each row in the CSV file
$results = Set-UserAndGroupMapping -MappingSettings $mappingSettings -Source $row.SourceValue -Destination $row.DestinationValue
# Output the source value for each row (for debugging or tracking purposes)
$row.SourceValue
}
# Export the user and group mappings to a file
Export-UserAndGroupMapping -MappingSettings $mappingSettings -Path "C:\FolderName\FileName"
ご自身の環境で動作するようにスクリプトを調整してください。以下にいくつかのガイドラインを示します。
$csvFile: スクリプトが CSV ファイルを呼び出すように、パスを調整します。
$table: 区切り文字は、CSV で列の項目を区切るために使用されている記号です。スクリプトがファイルと同じ区切り文字を使用していることを確認してください(CSV を Notepad で開くと簡単に確認できます)。
foreach: CSV ファイル内の値をループ処理します。詳細はこちらをご覧ください。
$results: パフォーマンスの問題を避けるため、結果は PowerShell ウィンドウに出力されず、results 変数に格納されます。
$row.sourcevalue: 進行状況を確認できるように、ソースの値を出力します。
Export-UserAndGroupMapping: 新しい ShareGate Migrate のユーザー マッピング ファイル(SGUM)を、任意の場所に任意の名前で保存できるようにパスを調整します。
SGUM ファイルを使用する
移行スクリプトで SGUM ファイルを使用するには、SGUM をインポートする次の行を追加します。
$mappingSettings = Import-UserAndGroupMapping -Path "C:\FolderName\FileName.sgum"
次に、Copy の行でマッピングを呼び出します(Copy-Site や Copy-Content など、すべてのコピー オプションで機能します)。コピー コマンドと同じ行に、次を追加します。
-MappingSettings $mappingSettings
SGUM ファイルは、Copy の移行オプションで Map users and groups メニューの Import ボタンをクリックしてインポートすることもできます。
この記事は人工知能を使用して翻訳されました。疑問がある場合は、元の英語版をご確認ください。
