---
schema_version: "1"
id: 8e0ff359c45d9e612ab113ca1a746159d1164552dbed5b2d9db91d611bc08712
title: "例: 移行計画のスクリプト作成"
collection: tableau
version: next
locale: ja-jp
portal_url: https://docs.salesforce.com/tableau/next/ja-jp/online/cmt-scripting_migration_example.md
canonical_url: https://help.tableau.com/v0.0/online/ja-jp/cmt-scripting_migration_example.htm
source_site: help.tableau.com
content_type: documentation
content_hash: fe3d995bb6092218f4f507842f193512f980f6ea249c1cf775e9e178752715a8
description: Sample script for scripting a multi-plan migration with the Content Migration Tool console runner.
---
[メイン コンテンツに進む](#main-content)

# 例: 移行計画のスクリプト作成

**注:** このトピックには、ニーズと環境を満たす複数の移行計画に対するスクリプトを作成するための基礎として使用できるサンプル スクリプトが含まれています。このスクリプトは、サンプルとしてのみ使用され、実際にそのまま使用することはできません。コンソール ランナーの使用手順に関する詳細については、[Tableau Content Migration Tool コンソール ランナーの使用](https://help.tableau.com/v0.0/online/ja-jp/cmt-deployment_console_runner.htm)を参照してください。

移行の実行に Tableau Content Migration Tool コマンド ライン ユーティリティを使用して、外部スケジューラ (Windows のタスク スケジューラなど) またはカスタム スクリプトから移行計画の実行を自動化できます。コンソール ランナーでは、.edt ファイルに保存された移行計画を一度に 1 つのみ実行します。グループとして実行する移行計画のグループがある場合は、Content Migration Tool コンソール ランナーと組み合わせたカスタム スクリプトを使用することができます。

次の例は PowerShell で記述されており、コンソール ランナーを使用して移行計画のリストをグループとして実行します。

次の例では、コードが以下の内容を示します。

- コンソール ランナーを使用して、グループとして複数の移行計画を実行する。
- グループ内の移行が 1 つでも失敗すると、計画グループの展開を直ちに停止する (オプション)。
- コンソール ランナーの終了コードを使用して、移行が失敗したか、警告がログに記録されたかを判断する。

\# List of migration plans to execute as a group.
$planFiles = @(
	'customer 1.tcmx',
	'customer 2.tcmx'
)

# True of false whether to continue with the next plan if a migration fails.
$continueOnFailure = $false
			
# Path to the CMT console runner executable
$runnerExe = 'C:\\Program Files (x86)\\Tableau\\Tableau Content Migration Tool\\tabcmt-runner.exe'

# Store the exit code from the previously run migration plan.
$lastResult = -1
			
# Loop through and run each migration plan one at a time.
$planFiles | % {
	$file = $\_
			
	if ($lastResult -ge 2 -and -not($continueOnFailure)) {
		Write-Warning "Skipping plan because previous migration failed. \`nSkipped plan: $file"
		return
	}
			
	Write-Verbose "Running migration plan: $file"
	& $runnerExe $file
       $lastResult = $LASTEXITCODE
 
 	if ($lastResult -ge 2) {
		Write-Error "Migration failed. See output or log file for error details.\`nPlan: $file" -ErrorAction 'Continue'
	}
	elseif ($lastResult -eq 1) {
		Write-Warning "Migration completed with warnings. See output or log file for warning details.\`nPlan: $file"
	}
}

## 実行可能なユーザー

移行計画のスクリプトを作成するには、次のものがすべて必要です。

- Content Migration Tool マシンでの管理者権限。
- Tableau サイトのユーザー アカウント (Explorer 以上の役割を持つ)。
- ソース サイトでのワークブックのダウンロード/コピーを保存パーミッション。
- 展開先サイトのパブリッシュ権限。