1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SharePoint Online(MS365)へのファイル移行

Last updated at Posted at 2021-12-01

SharePoint Onlineへの移行について

数えられる程度のファイル数なら手作業で移行してもいいですが、ファイルが多いようならMicrosoft公式からSPMT(SharePoint Migration Tool)というツールが提供されているのでそれを使用するのが良いと思います。
このツールはGUIとPowerShellによるCUIの両方をサポートしています。
この記事ではCUIを使用してオンプレミスのファイルをMicrosoft 365(旧Office 365)のSharePoint Onlineへ移行する方法を記述します。

SPMTインストール

以下より、SPMTをインストールしてください。
https://docs.microsoft.com/ja-jp/sharepointmigration/how-to-use-the-sharepoint-migration-tool

PowerShellスクリプト作成

JSONファイル(spmt.json)から移行タスク情報を読み込んで実行します。
ユーザー名、パスワードは1行目で別ファイル(.env)から読み取っています。
3つのファイルは同じ階層に置きます。JSONファイルはSJISにしてください。

migrationSharePoint.ps1
$conf = Get-Content .env -Raw | ConvertFrom-StringData

# Define SharePoint target#
$UserName = $conf.msUserName
$PassWord = ConvertTo-SecureString -String $conf.msUserPassword -AsPlainText -Force
$SPOCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $UserName, $PassWord

# Import SPMT Migration Module#
Import-Module Microsoft.SharePoint.MigrationTool.PowerShell

# Register the SPMT session with SharePoint credentials#
Register-SPMTMigration -SPOCredential $SPOCredential -Force

# Load JSON:
$jsonItems = Get-Content -Raw -Path "./spmt.json" | ConvertFrom-Json
ForEach ($taskItem in $jsonItems.Tasks)
{
    $jsonString = ConvertTo-Json $taskItem -Depth 100
    Add-SPMTTask -JsonDefinition $jsonString
}

# Start Migration in the console. #
Start-SPMTMigration
.env
msUserName=urushibata@example.onmicrosoft.com
msUserPassword=12345678
spmt.json
{
    "Tasks": [
        {
            "SourcePath": "C:\\\\Users\\urushibata\\Desktop\\移行テスト",
            "TargetPath": "https://my-company.sharepoint.com/sites/traial",
            "TargetList": "Shared Documents",
            "TargetListRelativePath": ""
        }
    ]
}

SourcePath・・・移行元パス。ファイルサーバーへのパスでもオンプレミスのSharePointのURLでも可能です。
TargetPath・・・移行先のSharePointのサイトのルートパスを設定します。
TargetList・・・ドキュメントを指定しています。ここで結構はまったのですが、だいたいのMSのマニュアルには「Documents」と書いてあったのですが「Documents」では403エラーが発生します。「Shared Documents」が正しいです。ドキュメントのルートのURLが「Shared%20Documents」となっているのを確認してください。
TargetListRelativePath・・・TargetList以下のサブフォルダを指定する場合設定します。

スクリプト実行

スクリプトを実行すれば完了します。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?