---
schema_version: "1"
id: d8eecd49d7447daa3c6c97ddb7584194f25a364ad5cf73f189d70ef4fc4b3484
title: "ตัวอย่าง: การเขียนสคริปต์แผนการย้าย"
collection: tableau
version: next
locale: th-th
portal_url: https://docs.salesforce.com/tableau/next/th-th/online/cmt-scripting_migration_example.md
canonical_url: https://help.tableau.com/v0.0/online/th-th/cmt-scripting_migration_example.htm
source_site: help.tableau.com
content_type: documentation
content_hash: afdbf20280e765c708dcef60d51689f140f8c3f02dca471a06be62c5556a8548
description: Sample script for scripting a multi-plan migration with the Content Migration Tool console runner.
---
[ข้ามไปยังเนื้อหาหลัก](#main-content)

# ตัวอย่าง: การเขียนสคริปต์แผนการย้าย

**หมายเหตุ:** หัวข้อนี้มีสคริปต์ตัวอย่างที่คุณสามารถใช้เป็นพื้นฐานสำหรับการเขียนสคริปต์การย้ายแบบหลายแผนที่ตอบโจทย์ความต้องการของคุณและสภาพแวดล้อมได้ โดยสคริปต์นี้มีจุดประสงค์เพื่อใช้เป็นตัวอย่างเท่านั้น และไม่ได้มีไว้เพื่อเรียกใช้ตามเดิม โปรดดูคำแนะนำโดยละเอียดเกี่ยวกับการใช้ตัวเรียกใช้คอนโซลที่[การใช้โปรแกรมรันคอนโซลของ Content Migration Tool ของ Tableau](https://help.tableau.com/v0.0/online/th-th/cmt-deployment_console_runner.htm)

ยูทิลิตี้บรรทัดคำสั่ง Content Migration Tool ของ Tableau สำหรับการเรียกใช้การย้ายสามารถใช้เพื่อทำให้การเรียกใช้แผนการย้ายจากเครื่องจัดตารางเวลาภายนอก (เช่น Windows Task Scheduler) หรือสคริปต์ที่กำหนดเองเป็นแบบอัตโนมัติได้ ตัวเรียกใช้คอนโซลเรียกใช้แผนการย้าย (จัดเก็บในไฟล์ .edt) ได้ครั้งละหนึ่งรายการเท่านั้น หากมีกลุ่มของแผนการย้ายที่ต้องการเรียกใช้เป็นกลุ่ม คุณสามารถใช้สคริปต์ที่กำหนดเองร่วมกับตัวเรียกใช้คอนโซล Content Migration Tool ได้

ตัวอย่างด้านล่างเขียนขึ้นใน PowerShell และใช้ตัวเรียกใช้คอนโซลเพื่อดำเนินการรายการแผนการย้ายเป็นกลุ่ม

ตัวอย่างโค้ดต่อไปนี้จะแสดง

- การเรียกใช้แผนการย้ายหลายรายการเป็นกลุ่มโดยใช้ตัวเรียกใช้คอนโซล
- การเลือกหยุดการปรับใช้ของกลุ่มแผนทันทีเมื่อการย้ายเดียวในกลุ่มไม่สำเร็จ
- การใช้โค้ดการออกของตัวเรียกใช้คอนโซลเพื่อกำหนดว่าการย้ายไม่สำเร็จหรือบันทึกคำเตือน

\# 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 หรือสูงกว่า
- ดูและดาวน์โหลดเวิร์กบุ๊ก/บันทึกสิทธิ์การคัดลอกบนไซต์ต้นทาง
- สิทธิ์การเผยแพร่สำหรับไซต์ปลายทาง