

第 5 版 (V5) AWS Tools for PowerShell 已發行！

如需有關中斷變更和遷移應用程式的資訊，請參閱[遷移主題](https://docs.aws.amazon.com/powershell/v5/userguide/migrating-v5.html)。

 [https://docs.aws.amazon.com/powershell/v5/userguide/migrating-v5.html](https://docs.aws.amazon.com/powershell/v5/userguide/migrating-v5.html)

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# AWS DMS 使用 Tools for PowerShell V5 的範例
<a name="powershell_database-migration-service_code_examples"></a>

下列程式碼範例示範如何使用 AWS Tools for PowerShell V5 搭配 來執行動作和實作常見案例 AWS DMS。

*Actions* 是大型程式的程式碼摘錄，必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數，但您可以在其相關情境中查看內容中的動作。

每個範例均包含完整原始碼的連結，您可在連結中找到如何設定和執行內容中程式碼的相關指示。

**Topics**
+ [動作](#actions)

## 動作
<a name="actions"></a>

### `New-DMSReplicationTask`
<a name="database-migration-service_CreateReplicationTask_powershell_topic"></a>

以下程式碼範例顯示如何使用 `New-DMSReplicationTask`。

**Tools for PowerShell V5**  
**範例 1：此範例會建立新的 AWS Database Migration Service 複寫任務，使用 CdcStartTime 而非 CdcStartPosition。MigrationType 設定為 "full-load-and-cdc"，意思是目標資料表必須為空白。新任務會加上具有 Stage 索引鍵和 Test 鍵值的標籤。如需此 cmdlet 所用值的詳細資訊，請參閱《 AWS Database Migration Service 使用者指南》中的建立任務 (https：//https://docs.aws.amazon.com/dms/latest/userguide/CHAP\$1Tasks.Creating.html)。**  

```
New-DMSReplicationTask -ReplicationInstanceArn "arn:aws:dms:us-east-1:123456789012:rep:EXAMPLE66XFJUWATDJGBEXAMPLE"`
  -CdcStartTime "2019-08-08T12:12:12"`
  -CdcStopPosition "server_time:2019-08-09T12:12:12"`
  -MigrationType "full-load-and-cdc"`
  -ReplicationTaskIdentifier "task1"`
  -ReplicationTaskSetting ""`
  -SourceEndpointArn "arn:aws:dms:us-east-1:123456789012:endpoint:EXAMPLEW5UANC7Y3P4EEXAMPLE"`
  -TableMapping "file:////home/testuser/table-mappings.json"`
  -Tag @{"Key"="Stage";"Value"="Test"}`
  -TargetEndpointArn "arn:aws:dms:us-east-1:123456789012:endpoint:EXAMPLEJZASXWHTWCLNEXAMPLE"
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [CreateReplicationTask](https://docs.aws.amazon.com/powershell/v5/reference)。