

Versi 5 (V5) dari Alat AWS untuk PowerShell telah dirilis\$1

Untuk informasi tentang melanggar perubahan dan memigrasi aplikasi Anda, lihat [topik migrasi](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)

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Contoh DynamoDB menggunakan Alat untuk V5 PowerShell
<a name="powershell_dynamodb_code_examples"></a>

Contoh kode berikut menunjukkan cara melakukan tindakan dan mengimplementasikan skenario umum dengan menggunakan Alat AWS untuk PowerShell V5 dengan DynamoDB.

*Tindakan* merupakan kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.

Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.

**Topics**
+ [Tindakan](#actions)

## Tindakan
<a name="actions"></a>

### `Add-DDBIndexSchema`
<a name="dynamodb_Add-DDBIndexSchema_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Add-DDBIndexSchema`.

**Alat untuk PowerShell V5**  
**Contoh 1: Membuat TableSchema objek kosong dan menambahkan definisi indeks sekunder lokal baru sebelum menulis TableSchema objek ke pipeline.**  

```
$schema | Add-DDBIndexSchema -IndexName "LastPostIndex" -RangeKeyName "LastPostDateTime" -RangeKeyDataType "S" -ProjectionType "keys_only"
$schema = New-DDBTableSchema
```
**Output:**  

```
AttributeSchema                             KeySchema                                   LocalSecondaryIndexSchema
---------------                             ---------                                   -------------------------
{LastPostDateTime}                          {}                                          {LastPostIndex}
```
**Contoh 2: Menambahkan definisi indeks sekunder lokal baru ke TableSchema objek yang disediakan sebelum menulis TableSchema objek kembali ke pipeline. TableSchema Objek juga dapat diberikan menggunakan parameter -Schema.**  

```
New-DDBTableSchema | Add-DDBIndexSchema -IndexName "LastPostIndex" -RangeKeyName "LastPostDateTime" -RangeKeyDataType "S" -ProjectionType "keys_only"
```
**Output:**  

```
AttributeSchema                             KeySchema                                   LocalSecondaryIndexSchema
---------------                             ---------                                   -------------------------
{LastPostDateTime}                          {}                                          {LastPostIndex}
```
+  Untuk detail API, lihat [Menambahkan DDBIndex Skema](https://docs.aws.amazon.com/powershell/v5/reference) di *Referensi Alat AWS untuk PowerShell Cmdlet (*V5). 

### `Add-DDBKeySchema`
<a name="dynamodb_Add-DDBKeySchema_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Add-DDBKeySchema`.

**Alat untuk PowerShell V5**  
**Contoh 1: Membuat TableSchema objek kosong dan menambahkan entri definisi kunci dan atribut ke dalamnya menggunakan data kunci yang ditentukan sebelum menulis TableSchema objek ke pipeline. Tipe kunci dinyatakan sebagai 'HASH' secara default; gunakan - KeyType paameter dengan nilai 'RANGE' untuk mendeklarasikan kunci rentang.**  

```
$schema = New-DDBTableSchema
$schema | Add-DDBKeySchema -KeyName "ForumName" -KeyDataType "S"
```
**Output:**  

```
AttributeSchema                             KeySchema                                   LocalSecondaryIndexSchema
---------------                             ---------                                   -------------------------
{ForumName}                                 {ForumName}                                 {}
```
**Contoh 2: Menambahkan entri definisi kunci dan atribut baru ke TableSchema objek yang disediakan sebelum menulis TableSchema objek ke pipeline. Tipe kunci dinyatakan sebagai 'HASH' secara default; gunakan - KeyType paameter dengan nilai 'RANGE' untuk mendeklarasikan kunci rentang. TableSchema Objek juga dapat diberikan menggunakan parameter -Schema.**  

```
New-DDBTableSchema | Add-DDBKeySchema -KeyName "ForumName" -KeyDataType "S"
```
**Output:**  

```
AttributeSchema                             KeySchema                                   LocalSecondaryIndexSchema
---------------                             ---------                                   -------------------------
{ForumName}                                 {ForumName}                                 {}
```
+  Untuk detail API, lihat [Menambahkan DDBKey Skema](https://docs.aws.amazon.com/powershell/v5/reference) di *Referensi Alat AWS untuk PowerShell Cmdlet (*V5). 

### `ConvertFrom-DDBItem`
<a name="dynamodb_ConvertFrom-DDBItem_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`ConvertFrom-DDBItem`.

**Alat untuk PowerShell V5**  
**Contoh 1: ConvertFrom - DDBItem digunakan untuk mengonversi hasil Get-DDBItem dari hashtable AttributeValues DynamoDB ke hashtable tipe umum seperti string dan double.**  

```
@{
    SongTitle = 'Somewhere Down The Road'
    Artist    = 'No One You Know'
} | ConvertTo-DDBItem

Get-DDBItem -TableName 'Music' -Key $key | ConvertFrom-DDBItem
```
**Output:**  

```
Name                           Value
----                           -----
Genre                          Country
Artist                         No One You Know
Price                          1.94
CriticRating                   9
SongTitle                      Somewhere Down The Road
AlbumTitle                     Somewhat Famous
```
+  Untuk detail API, lihat [ConvertFrom- DDBItem](https://docs.aws.amazon.com/powershell/v5/reference) di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

### `ConvertTo-DDBItem`
<a name="dynamodb_ConvertTo-DDBItem_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`ConvertTo-DDBItem`.

**Alat untuk PowerShell V5**  
**Contoh 1: Contoh untuk mengubah hashtable menjadi kamus nilai atribut DynamoDB.**  

```
@{
    SongTitle = 'Somewhere Down The Road'
    Artist    = 'No One You Know'
} | ConvertTo-DDBItem

Key       Value
---       -----
SongTitle Amazon.DynamoDBv2.Model.AttributeValue
Artist    Amazon.DynamoDBv2.Model.AttributeValue
```
**Contoh 2: Contoh untuk mengubah hashtable menjadi kamus nilai atribut DynamoDB.**  

```
@{
    MyMap        = @{
        MyString = 'my string'
    }
    MyStringSet  = [System.Collections.Generic.HashSet[String]]@('my', 'string')
    MyNumericSet = [System.Collections.Generic.HashSet[Int]]@(1, 2, 3)
    MyBinarySet  = [System.Collections.Generic.HashSet[System.IO.MemoryStream]]@(
        ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes('my'))),
        ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes('string')))
    )
    MyList1      = @('my', 'string')
    MyList2      = [System.Collections.Generic.List[Int]]@(1, 2)
    MyList3      = [System.Collections.ArrayList]@('one', 2, $true)
} | ConvertTo-DDBItem
```
**Output:**  

```
Key          Value
---          -----
MyStringSet  Amazon.DynamoDBv2.Model.AttributeValue
MyList1      Amazon.DynamoDBv2.Model.AttributeValue
MyNumericSet Amazon.DynamoDBv2.Model.AttributeValue
MyList2      Amazon.DynamoDBv2.Model.AttributeValue
MyBinarySet  Amazon.DynamoDBv2.Model.AttributeValue
MyMap        Amazon.DynamoDBv2.Model.AttributeValue
MyList3      Amazon.DynamoDBv2.Model.AttributeValue
```
+  Untuk detail API, lihat [ConvertTo- DDBItem](https://docs.aws.amazon.com/powershell/v5/reference) di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

### `Get-DDBBatchItem`
<a name="dynamodb_BatchGetItem_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Get-DDBBatchItem`.

**Alat untuk PowerShell V5**  
**Contoh 1: Mendapatkan item dengan SongTitle “Somewhere Down The Road” dari tabel DynamoDB 'Music' dan 'Songs'.**  

```
$key = @{
    SongTitle = 'Somewhere Down The Road'
    Artist = 'No One You Know'
} | ConvertTo-DDBItem

$keysAndAttributes = New-Object Amazon.DynamoDBv2.Model.KeysAndAttributes
$list = New-Object 'System.Collections.Generic.List[System.Collections.Generic.Dictionary[String, Amazon.DynamoDBv2.Model.AttributeValue]]'
$list.Add($key)
$keysAndAttributes.Keys = $list

$requestItem = @{
    'Music' = [Amazon.DynamoDBv2.Model.KeysAndAttributes]$keysAndAttributes
    'Songs' = [Amazon.DynamoDBv2.Model.KeysAndAttributes]$keysAndAttributes
}

$batchItems = Get-DDBBatchItem -RequestItem $requestItem
$batchItems.GetEnumerator() | ForEach-Object {$PSItem.Value} | ConvertFrom-DDBItem
```
**Output:**  

```
Name                           Value
----                           -----
Artist                         No One You Know
SongTitle                      Somewhere Down The Road
AlbumTitle                     Somewhat Famous
CriticRating                   10
Genre                          Country
Price                          1.94
Artist                         No One You Know
SongTitle                      Somewhere Down The Road
AlbumTitle                     Somewhat Famous
CriticRating                   10
Genre                          Country
Price                          1.94
```
+  Untuk detail API, lihat [BatchGetItem](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

### `Get-DDBItem`
<a name="dynamodb_GetItem_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Get-DDBItem`.

**Alat untuk PowerShell V5**  
**Contoh 1: Mengembalikan item DynamoDB dengan SongTitle kunci partisi dan kunci sort Artist.**  

```
$key = @{
  SongTitle = 'Somewhere Down The Road'
  Artist = 'No One You Know'
} | ConvertTo-DDBItem

Get-DDBItem -TableName 'Music' -Key $key | ConvertFrom-DDBItem
```
**Output:**  

```
Name                           Value
----                           -----
Genre                          Country
SongTitle                      Somewhere Down The Road
Price                          1.94
Artist                         No One You Know
CriticRating                   9
AlbumTitle                     Somewhat Famous
```
+  Untuk detail API, lihat [GetItem](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

### `Get-DDBTable`
<a name="dynamodb_DescribeTable_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Get-DDBTable`.

**Alat untuk PowerShell V5**  
**Contoh 1: Mengembalikan rincian tabel yang ditentukan.**  

```
Get-DDBTable -TableName "myTable"
```
+  Untuk detail API, lihat [DescribeTable](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

### `Get-DDBTableList`
<a name="dynamodb_ListTables_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Get-DDBTableList`.

**Alat untuk PowerShell V5**  
**Contoh 1: Mengembalikan rincian semua tabel, secara otomatis iterasi sampai layanan menunjukkan tidak ada tabel lebih lanjut.**  

```
Get-DDBTableList
```
+  Untuk detail API, lihat [ListTables](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

### `Invoke-DDBQuery`
<a name="dynamodb_Query_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Invoke-DDBQuery`.

**Alat untuk PowerShell V5**  
**Contoh 1: Memanggil query yang mengembalikan item DynamoDB dengan yang ditentukan dan Artist. SongTitle **  

```
$invokeDDBQuery = @{
    TableName = 'Music'
    KeyConditionExpression = ' SongTitle = :SongTitle and Artist = :Artist'
    ExpressionAttributeValues = @{
        ':SongTitle' = 'Somewhere Down The Road'
        ':Artist' = 'No One You Know'
    } | ConvertTo-DDBItem
}
Invoke-DDBQuery @invokeDDBQuery | ConvertFrom-DDBItem
```
**Output:**  

```
Name                           Value
----                           -----
Genre                          Country
Artist                         No One You Know
Price                          1.94
CriticRating                   9
SongTitle                      Somewhere Down The Road
AlbumTitle                     Somewhat Famous
```
+  Untuk detail API, lihat [Kueri](https://docs.aws.amazon.com/powershell/v5/reference) di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

### `Invoke-DDBScan`
<a name="dynamodb_Scan_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Invoke-DDBScan`.

**Alat untuk PowerShell V5**  
**Contoh 1: Mengembalikan semua item dalam tabel Musik.**  

```
Invoke-DDBScan -TableName 'Music' | ConvertFrom-DDBItem
```
**Output:**  

```
Name                           Value
----                           -----
Genre                          Country
Artist                         No One You Know
Price                          1.94
CriticRating                   9
SongTitle                      Somewhere Down The Road
AlbumTitle                     Somewhat Famous
Genre                          Country
Artist                         No One You Know
Price                          1.98
CriticRating                   8.4
SongTitle                      My Dog Spot
AlbumTitle                     Hey Now
```
**Contoh 2: Mengembalikan item dalam tabel Musik dengan CriticRating lebih besar dari atau sama dengan sembilan.**  

```
$scanFilter = @{
        CriticRating = [Amazon.DynamoDBv2.Model.Condition]@{
            AttributeValueList = @(@{N = '9'})
            ComparisonOperator = 'GE'
        }
    }
    Invoke-DDBScan -TableName 'Music' -ScanFilter $scanFilter | ConvertFrom-DDBItem
```
**Output:**  

```
Name                           Value
----                           -----
Genre                          Country
Artist                         No One You Know
Price                          1.94
CriticRating                   9
SongTitle                      Somewhere Down The Road
AlbumTitle                     Somewhat Famous
```
+  Untuk detail API, lihat [Memindai](https://docs.aws.amazon.com/powershell/v5/reference) di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

### `New-DDBTable`
<a name="dynamodb_CreateTable_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`New-DDBTable`.

**Alat untuk PowerShell V5**  
**Contoh 1: Contoh ini membuat tabel bernama Thread yang memiliki kunci utama yang terdiri dari 'ForumName' (hash tipe kunci) dan 'Subject' (rentang tipe kunci). Skema yang digunakan untuk membangun tabel dapat disalurkan ke setiap cmdlet seperti yang ditunjukkan atau ditentukan menggunakan parameter -Schema.**  

```
$schema = New-DDBTableSchema
$schema | Add-DDBKeySchema -KeyName "ForumName" -KeyDataType "S"
$schema | Add-DDBKeySchema -KeyName "Subject" -KeyType RANGE -KeyDataType "S"
$schema | New-DDBTable -TableName "Thread" -ReadCapacity 10 -WriteCapacity 5
```
**Output:**  

```
AttributeDefinitions   : {ForumName, Subject}
TableName              : Thread
KeySchema              : {ForumName, Subject}
TableStatus            : CREATING
CreationDateTime       : 10/28/2013 4:39:49 PM
ProvisionedThroughput  : Amazon.DynamoDBv2.Model.ProvisionedThroughputDescription
TableSizeBytes         : 0
ItemCount              : 0
LocalSecondaryIndexes  : {}
```
**Contoh 2: Contoh ini membuat tabel bernama Thread yang memiliki kunci utama yang terdiri dari 'ForumName' (hash tipe kunci) dan 'Subject' (rentang tipe kunci). Indeks sekunder lokal juga didefinisikan. Kunci indeks sekunder lokal akan diatur secara otomatis dari kunci hash utama pada tabel (ForumName). Skema yang digunakan untuk membangun tabel dapat disalurkan ke setiap cmdlet seperti yang ditunjukkan atau ditentukan menggunakan parameter -Schema.**  

```
$schema = New-DDBTableSchema
$schema | Add-DDBKeySchema -KeyName "ForumName" -KeyDataType "S"
$schema | Add-DDBKeySchema -KeyName "Subject" -KeyDataType "S"
$schema | Add-DDBIndexSchema -IndexName "LastPostIndex" -RangeKeyName "LastPostDateTime" -RangeKeyDataType "S" -ProjectionType "keys_only"
$schema | New-DDBTable -TableName "Thread" -ReadCapacity 10 -WriteCapacity 5
```
**Output:**  

```
AttributeDefinitions   : {ForumName, LastPostDateTime, Subject}
TableName              : Thread
KeySchema              : {ForumName, Subject}
TableStatus            : CREATING
CreationDateTime       : 10/28/2013 4:39:49 PM
ProvisionedThroughput  : Amazon.DynamoDBv2.Model.ProvisionedThroughputDescription
TableSizeBytes         : 0
ItemCount              : 0
LocalSecondaryIndexes  : {LastPostIndex}
```
**Contoh 3: Contoh ini menunjukkan cara menggunakan pipeline tunggal untuk membuat tabel bernama Thread yang memiliki kunci utama yang terdiri dari 'ForumName' (hash tipe kunci) dan 'Subjek' (rentang tipe kunci) dan indeks sekunder lokal. DDBKeyAdd-Schema dan Add- DDBIndex Schema membuat TableSchema objek baru untuk Anda jika salah satu tidak dipasok dari pipeline atau parameter -Schema.**  

```
New-DDBTableSchema |
  Add-DDBKeySchema -KeyName "ForumName" -KeyDataType "S" |
  Add-DDBKeySchema -KeyName "Subject" -KeyDataType "S" |
  Add-DDBIndexSchema -IndexName "LastPostIndex" `
                     -RangeKeyName "LastPostDateTime" `
                     -RangeKeyDataType "S" `
                     -ProjectionType "keys_only" |
  New-DDBTable -TableName "Thread" -ReadCapacity 10 -WriteCapacity 5
```
**Output:**  

```
AttributeDefinitions   : {ForumName, LastPostDateTime, Subject}
TableName              : Thread
KeySchema              : {ForumName, Subject}
TableStatus            : CREATING
CreationDateTime       : 10/28/2013 4:39:49 PM
ProvisionedThroughput  : Amazon.DynamoDBv2.Model.ProvisionedThroughputDescription
TableSizeBytes         : 0
ItemCount              : 0
LocalSecondaryIndexes  : {LastPostIndex}
```
+  Untuk detail API, lihat [CreateTable](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

### `New-DDBTableSchema`
<a name="dynamodb_New-DDBTableSchema_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`New-DDBTableSchema`.

**Alat untuk PowerShell V5**  
**Contoh 1: Membuat TableSchema objek kosong yang siap menerima definisi kunci dan indeks untuk digunakan dalam membuat tabel Amazon DynamoDB baru. Objek yang dikembalikan dapat disalurkan ke dalam Add- DDBKey Schema, Add- DDBIndex Schema dan New- DDBTable cmdlet atau diteruskan ke mereka menggunakan parameter -Schema pada setiap cmdlet.**  

```
New-DDBTableSchema
```
**Output:**  

```
AttributeSchema                             KeySchema                                   LocalSecondaryIndexSchema
---------------                             ---------                                   -------------------------
{}                                          {}                                          {}
```
+  Untuk detail API, lihat [DDBTableSkema Baru di](https://docs.aws.amazon.com/powershell/v5/reference) *Referensi Alat AWS untuk PowerShell Cmdlet (*V5). 

### `Remove-DDBItem`
<a name="dynamodb_DeleteItem_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Remove-DDBItem`.

**Alat untuk PowerShell V5**  
**Contoh 1: Menghapus item DynamoDB yang cocok dengan kunci yang disediakan.**  

```
$key = @{
    SongTitle = 'Somewhere Down The Road'
    Artist = 'No One You Know'
} | ConvertTo-DDBItem
Remove-DDBItem -TableName 'Music' -Key $key -Confirm:$false
```
+  Untuk detail API, lihat [DeleteItem](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

### `Remove-DDBTable`
<a name="dynamodb_DeleteTable_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Remove-DDBTable`.

**Alat untuk PowerShell V5**  
**Contoh 1: Menghapus tabel yang ditentukan. Anda diminta untuk konfirmasi sebelum operasi berlangsung.**  

```
Remove-DDBTable -TableName "myTable"
```
**Contoh 2: Menghapus tabel yang ditentukan. Anda tidak diminta untuk konfirmasi sebelum operasi berlangsung.**  

```
Remove-DDBTable -TableName "myTable" -Force
```
+  Untuk detail API, lihat [DeleteTable](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

### `Set-DDBBatchItem`
<a name="dynamodb_BatchWriteItem_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Set-DDBBatchItem`.

**Alat untuk PowerShell V5**  
**Contoh 1: Membuat item baru, atau mengganti item yang ada dengan item baru di tabel DynamoDB Musik dan Lagu.**  

```
$item = @{
    SongTitle = 'Somewhere Down The Road'
    Artist = 'No One You Know'
    AlbumTitle = 'Somewhat Famous'
    Price = 1.94
    Genre = 'Country'
    CriticRating = 10.0
} | ConvertTo-DDBItem

$writeRequest = New-Object Amazon.DynamoDBv2.Model.WriteRequest
$writeRequest.PutRequest = [Amazon.DynamoDBv2.Model.PutRequest]$item

$requestItem = @{
    'Music' = [Amazon.DynamoDBv2.Model.WriteRequest]($writeRequest)
    'Songs' = [Amazon.DynamoDBv2.Model.WriteRequest]($writeRequest)
}

Set-DDBBatchItem -RequestItem $requestItem
```
+  Untuk detail API, lihat [BatchWriteItem](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

### `Set-DDBItem`
<a name="dynamodb_PutItem_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Set-DDBItem`.

**Alat untuk PowerShell V5**  
**Contoh 1: Membuat item baru, atau mengganti item yang sudah ada dengan item baru.**  

```
$item = @{
  SongTitle = 'Somewhere Down The Road'
  Artist = 'No One You Know'
        AlbumTitle = 'Somewhat Famous'
        Price = 1.94
        Genre = 'Country'
        CriticRating = 9.0
} | ConvertTo-DDBItem
Set-DDBItem -TableName 'Music' -Item $item
```
+  Untuk detail API, lihat [PutItem](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

### `Update-DDBItem`
<a name="dynamodb_UpdateItem_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Update-DDBItem`.

**Alat untuk PowerShell V5**  
**Contoh 1: Menetapkan atribut genre ke 'Rap' pada item DynamoDB dengan SongTitle kunci partisi dan Artis kunci sortir.**  

```
$key = @{
    SongTitle = 'Somewhere Down The Road'
    Artist = 'No One You Know'
} | ConvertTo-DDBItem

$updateDdbItem = @{
    TableName = 'Music'
    Key = $key
    UpdateExpression = 'set Genre = :val1'
    ExpressionAttributeValue = (@{
        ':val1' = ([Amazon.DynamoDBv2.Model.AttributeValue]'Rap')
    })
}
Update-DDBItem @updateDdbItem
```
**Output:**  

```
Name                           Value
----                           -----
Genre                          Rap
```
+  Untuk detail API, lihat [UpdateItem](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

### `Update-DDBTable`
<a name="dynamodb_UpdateTable_powershell_topic"></a>

Contoh kode berikut menunjukkan cara menggunakan`Update-DDBTable`.

**Alat untuk PowerShell V5**  
**Contoh 1: Memperbarui throughput yang disediakan untuk tabel yang diberikan.**  

```
Update-DDBTable -TableName "myTable" -ReadCapacity 10 -WriteCapacity 5
```
+  Untuk detail API, lihat [UpdateTable](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 