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

PowerShellでExplore画面にsite collectionを追加する

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

Explore画面でsite collectionを1つずつ追加することも、管理センターまたは中央管理に接続してファームまたはテナント内のすべてのsite collectionを追加することもできます。

個々の接続を1つずつ行わずに複数の特定のsite collectionをExplorerに接続するには、PowerShellスクリプトで-AddToExplorerパラメーターを使用します。

ヒント: Explorerから接続をエクスポート・インポートして、他のShareGate Migrateユーザーと共有することもできます。

ヒント: 追加した接続は、SettingsConnectionsセクションにあるConnection Managerにも保存され、表示・更新・削除ができます。ShareGate Migrateで接続を管理するを参照してください。

Explore画面に単一のsite collectionを追加する

次のスクリプトをお好みのPowerShellアプリケーションにコピー&ペーストします。

# Import the Sharegate module
Import-Module Sharegate

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

# Connect to the SharePoint site and add it to File Explorer
Connect-Site -Url "http://yourtenant.sharepoint.com/sites/yoursitecollection" -Username $myUsername -Password $myPassword -AddToExplorer

ご自身の環境に合わせてスクリプトを調整してください。以下はいくつかのガイドラインです。

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

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

  • -URL: URLをご自身のsite collectionのURLに置き換えます。

スクリプトの調整とテストが完了したら実行します。

ヒント: このスクリプトでは、URLが異なる複数のConnect-Site行を用意することで、複数のSite CollectionをExplorerに追加できます。接続するサイトが多い場合は、代わりに下記のCSVを使う方法をお勧めします。

CSVを使用して複数のsite collectionをExplorerに追加する

接続用のCSVガイドを作成する

  1. 新しいExcelドキュメントを作成します。

  2. 最初の列にURLという名前を付けます。

  3. Explorerに追加したいすべてのsite collectionのURLを一覧にします。

    mceclip0.png
  4. ファイルをCSVとして保存します。

スクリプトを作成する

次のスクリプトをお好みのPowerShellアプリケーションにコピー&ペーストします。

# Import the Sharegate module
Import-Module Sharegate

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

# Import the CSV file into a table (array of objects)
$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によって翻訳されています。ご不明な点がある場合は、英語の原文をご確認ください。

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