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

PowerShell で Explorer の接続をエクスポートおよびインポートする

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

Explorer の接続を共有するには、Export-Connections を使って接続をエクスポートし、PowerShell のforeachループを使ってインポートします。

Explorer の接続をエクスポートする

以下のスクリプトをコピーして、お好みの PowerShell アプリケーションに貼り付けます。

# Import the Sharegate module
Import-Module Sharegate

# Export Sharegate connections to a CSV file
Export-Connections -Path "C:\ExportedConnections.csv"

お好みの場所に、任意の名前と拡張子でファイルをエクスポートするようにパスを調整してください。.csv または .xlsx 形式で保存できます。

スクリプトを正しく調整したら、実行します。

Explorer の接続をインポートする

以下のスクリプトをコピーして、お好みの PowerShell アプリケーションに貼り付けます。

# Import the Sharegate module
Import-Module Sharegate

# Define the path to the exported connections CSV file
$csvFile = "C:\ExportedConnections.csv"

# Import the CSV file into a table
$table = Import-Csv $csvFile

# Define user credentials
$myUsername = "myusername"
$myPassword = ConvertTo-SecureString 'mypassword' -AsPlainText -Force

# Loop through each row in the CSV table and connect to the specified SharePoint site
foreach ($row in $table) {
Connect-Site -Url $row.URL -Username $myUsername -Password $myPassword -AddToExplorer
}

スクリプトが自分の環境で動作するように調整してください。以下にいくつかのガイドラインを示します。

  • $csvFile: エクスポートした CSV ファイルを指すようにパスを調整します。

  • $myUsername と $myPassword:「myusername」と「mypassword」を、ご自身の SharePoint または Microsoft 365 の資格情報に置き換えます。

  • Connect-Site: 認証方法を変更する必要がある場合は、Connect-Site の記事で方法を確認できます。

  • foreach: CSV ファイルの各行に対して、括弧内のコマンドを繰り返し実行します。ここでは、ShareGate Migrate の Explorer に接続を追加します。

スクリプトを正しく調整してテストしたら、実行します。

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

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