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

CSVファイルからユーザー マッピングを作成する

注: 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ファイルには、SourceValueDestinationValue の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ファイルを開くと簡単に確認できます)。

  • foreach: CSVファイル内の値を繰り返し処理します。詳細はこちらをご確認ください。

  • $results: パフォーマンスの問題を避けるため、結果はPowerShellウィンドウに出力する代わりにresultsという変数に保存されます。

  • $row.sourcevalue: 進行状況を確認できるように、ソース値を出力します。

  • Export-UserAndGroupMapping: 新しいShareGate Migrateユーザーマッピングファイル(SGUM)を、お好みの場所に好きな名前で保存するようパスを調整します。

SGUMファイルを使用する

次の行を使うと、移行スクリプトでSGUMファイルをインポートできます。

$mappingSettings = Import-UserAndGroupMapping -Path "C:\FolderName\FileName.sgum"

続いて、Copyの行でマッピングを呼び出します(Copy-SiteやCopy-Contentなど、すべてのコピー オプションで機能します)。コピー コマンドと同じ行に次を追加します。

-MappingSettings $mappingSettings

また、ユーザーとグループをマッピングするメニューのImportボタンをクリックして、ShareGate Migrateの移行オプションのCopyでSGUMファイルをインポートすることもできます。

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

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