---
schema_version: "1"
id: 3caff96e68e9213956a8960bf00aadb5832412673e295cea7143690bbb460a87
title: "Example: Scripting Migration Plans"
collection: tableau
version: next
locale: en-gb
portal_url: https://docs.salesforce.com/tableau/next/en-gb/server/cmt-scripting_migration_example.md
canonical_url: https://help.tableau.com/v0.0/server/en-gb/cmt-scripting_migration_example.htm
source_site: help.tableau.com
content_type: documentation
content_hash: b7c73794a6f8278d28df934e9fcf4de51cf8d12130530f803f1c914abf780ed0
description: Sample script for scripting a multi-plan migration with the Content Migration Tool console runner.
---
[Skip to main content](#main-content)

# Example: Scripting Migration Plans

**Note:** This topic includes a sample script you can use as the basis for scripting a multi-plan migration that satisfies your needs and environment. This script is intended to be used as a sample only, and not to be run as-is. For detailed instructions on using the console runner, see [Using the Tableau Content Migration Tool Console Runner](https://help.tableau.com/v0.0/server/en-gb/cmt-deployment_console_runner.htm).

Tableau Content Migration Tool command line utility for running migrations can be used to automate the running of a migration plan from an external scheduler (such as Windows Task Scheduler) or from a custom script. The console runner only runs one migration plan (stored in a .edt file) at a time. If you have a group of migration plans you want to run as a group, then you can use a custom script in combination with the Content Migration Tool console runner.

The example below is written in PowerShell and uses the console runner to execute a list of migration plans as a group.

The following example code demonstrates:

- Running multiple migration plans as a group using the console runner.
- Optionally halting deployment of the group of plans immediately when any single migration in the group fails.
- Using the console runner’s exit code to determine whether the migration failed or logged warnings.

\# 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"
	}
}

## Who can do this

To script migration plans, you must have all the following:

- Administrator permissions on the Content Migration Tool machine.
- Tableau site user account with an Explorer role or higher.
- View and Download Workbook/Save a Copy permissions on the source site.
- Publishing rights for the destination site.