

È stata rilasciata la versione 5 (V5) di\$1 AWS Strumenti per PowerShell 

Per informazioni sulle modifiche introduttive e sulla migrazione delle applicazioni, consulta l'argomento sulla [migrazione](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)

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# Esempi di Amazon SQS con Tools for V5 PowerShell
<a name="powershell_sqs_code_examples"></a>

I seguenti esempi di codice mostrano come eseguire azioni e implementare scenari comuni utilizzando la versione AWS Strumenti per PowerShell V5 con Amazon SQS.

Le *azioni* sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Sebbene le azioni mostrino come richiamare le singole funzioni del servizio, è possibile visualizzarle contestualizzate negli scenari correlati.

Ogni esempio include un link al codice sorgente completo, in cui vengono fornite le istruzioni su come configurare ed eseguire il codice nel contesto.

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

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

### `Add-SQSPermission`
<a name="sqs_AddPermission_powershell_topic"></a>

Il seguente esempio di codice mostra come usare. `Add-SQSPermission`

**Strumenti per PowerShell V5**  
**Esempio 1: Questo esempio consente all'utente specificato Account AWS di inviare messaggi dalla coda specificata.**  

```
Add-SQSPermission -Action SendMessage -AWSAccountId 80398EXAMPLE -Label SendMessagesFromMyQueue -QueueUrl https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue
```
+  Per i dettagli sull'API, vedere [AddPermission](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

### `Clear-SQSQueue`
<a name="sqs_PurgeQueue_powershell_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `Clear-SQSQueue`

**Strumenti per PowerShell V5**  
**Esempio 1: questo esempio elimina tutti i messaggi dalla coda specificata.**  

```
Clear-SQSQueue -QueueUrl https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue
```
+  Per i dettagli sull'API, vedere [PurgeQueue](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

### `Edit-SQSMessageVisibility`
<a name="sqs_ChangeMessageVisibility_powershell_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `Edit-SQSMessageVisibility`

**Strumenti per PowerShell V5**  
**Esempio 1: questo esempio modifica il timeout della visibilità del messaggio con l’handle di ricezione specificato nella coda specificata portandolo a 10 ore (10 ore \$1 60 minuti \$1 60 secondi = 36000 secondi).**  

```
Edit-SQSMessageVisibility -QueueUrl https://sqs.us-east-1.amazonaws.com/8039EXAMPLE/MyQueue -ReceiptHandle AQEBgGDh...J/Iqww== -VisibilityTimeout 36000
```
+  Per i dettagli sull'API, vedere [ChangeMessageVisibility](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

### `Edit-SQSMessageVisibilityBatch`
<a name="sqs_ChangeMessageVisibilityBatch_powershell_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `Edit-SQSMessageVisibilityBatch`

**Strumenti per PowerShell V5**  
**Esempio 1: questo esempio modifica il timeout della visibilità di 2 messaggi con gli handle di ricezione specificati nella coda specificata. Il timeout della visibilità del primo messaggio viene impostato su 10 ore (10 ore \$1 60 minuti \$1 60 secondi = 36000 secondi). Il timeout della visibilità del secondo messaggio viene impostata su 5 ore (5 ore \$1 60 minuti \$1 60 secondi = 18000 secondi).**  

```
$changeVisibilityRequest1 = New-Object Amazon.SQS.Model.ChangeMessageVisibilityBatchRequestEntry
$changeVisibilityRequest1.Id = "Request1"
$changeVisibilityRequest1.ReceiptHandle = "AQEBd329...v6gl8Q=="
$changeVisibilityRequest1.VisibilityTimeout = 36000

$changeVisibilityRequest2 = New-Object Amazon.SQS.Model.ChangeMessageVisibilityBatchRequestEntry
$changeVisibilityRequest2.Id = "Request2"
$changeVisibilityRequest2.ReceiptHandle = "AQEBgGDh...J/Iqww=="
$changeVisibilityRequest2.VisibilityTimeout = 18000

Edit-SQSMessageVisibilityBatch -QueueUrl https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue -Entry $changeVisibilityRequest1, $changeVisibilityRequest2
```
**Output:**  

```
Failed    Successful                                                                    
------    ----------                                                                    
{}        {Request2, Request1}
```
+  Per i dettagli sull'API, vedere [ChangeMessageVisibilityBatch](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

### `Get-SQSDeadLetterSourceQueue`
<a name="sqs_ListDeadLetterSourceQueues_powershell_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `Get-SQSDeadLetterSourceQueue`

**Strumenti per PowerShell V5**  
**Esempio 1: Questo esempio elenca tutte le URLs code che si basano sulla coda specificata come coda di lettere morte.**  

```
Get-SQSDeadLetterSourceQueue -QueueUrl https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyDeadLetterQueue
```
**Output:**  

```
https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue
https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyOtherQueue
```
+  Per i dettagli sull'API, vedere [ListDeadLetterSourceQueues](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

### `Get-SQSQueue`
<a name="sqs_ListQueues_powershell_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `Get-SQSQueue`

**Strumenti per PowerShell V5**  
**Esempio 1: questo esempio elenca tutte le code.**  

```
Get-SQSQueue
```
**Output:**  

```
https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue
https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/AnotherQueue
https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/DeadLetterQueue
https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyOtherQueue
https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyDeadLetterQueue
```
**Esempio 2: questo esempio elenca qualsiasi coda che inizia con il nome specificato.**  

```
Get-SQSQueue -QueueNamePrefix My
```
**Output:**  

```
https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue
https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyOtherQueue
https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyDeadLetterQueue
```
+  Per i dettagli sull'API, vedere [ListQueues](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

### `Get-SQSQueueAttribute`
<a name="sqs_GetQueueAttributes_powershell_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `Get-SQSQueueAttribute`

**Strumenti per PowerShell V5**  
**Esempio 1: questo esempio elenca tutti gli attributi della coda specificata.**  

```
Get-SQSQueueAttribute -AttributeName All -QueueUrl https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue
```
**Output:**  

```
VisibilityTimeout                     : 30
DelaySeconds                          : 0
MaximumMessageSize                    : 262144
MessageRetentionPeriod                : 345600
ApproximateNumberOfMessages           : 0
ApproximateNumberOfMessagesNotVisible : 0
ApproximateNumberOfMessagesDelayed    : 0
CreatedTimestamp                      : 2/11/2015 5:53:35 PM
LastModifiedTimestamp                 : 12/29/2015 2:23:17 PM
QueueARN                              : arn:aws:sqs:us-east-1:80398EXAMPLE:MyQueue
Policy                                : {"Version":"2012-10-17",		 	 	 "Id":"arn:aws:sqs:us-east-1:80398EXAMPLE:MyQueue/SQSDefaultPolicy","Statement":[{"Sid":"Sid14
                                        495134224EX","Effect":"Allow","Principal":{"AWS":"*"},"Action":"SQS:SendMessage","Resource":"arn:aws:sqs:us-east-1:80
                                        398EXAMPLE:MyQueue","Condition":{"ArnEquals":{"aws:SourceArn":"arn:aws:sns:us-east-1:80398EXAMPLE:MyTopic"}}},{"Sid":
                                        "SendMessagesFromMyQueue","Effect":"Allow","Principal":{"AWS":"80398EXAMPLE"},"Action":"SQS:SendMessage","Resource":"
                                        arn:aws:sqs:us-east-1:80398EXAMPLE:MyQueue"}]}
Attributes                            : {[QueueArn, arn:aws:sqs:us-east-1:80398EXAMPLE:MyQueue], [ApproximateNumberOfMessages, 0], 
                                        [ApproximateNumberOfMessagesNotVisible, 0], [ApproximateNumberOfMessagesDelayed, 0]...}
```
**Esempio 2: questo esempio elenca separatamente solo gli attributi specificati della coda specificata.**  

```
Get-SQSQueueAttribute -AttributeName MaximumMessageSize, VisibilityTimeout -QueueUrl https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue
```
**Output:**  

```
VisibilityTimeout                     : 30
DelaySeconds                          : 0
MaximumMessageSize                    : 262144
MessageRetentionPeriod                : 345600
ApproximateNumberOfMessages           : 0
ApproximateNumberOfMessagesNotVisible : 0
ApproximateNumberOfMessagesDelayed    : 0
CreatedTimestamp                      : 2/11/2015 5:53:35 PM
LastModifiedTimestamp                 : 12/29/2015 2:23:17 PM
QueueARN                              : arn:aws:sqs:us-east-1:80398EXAMPLE:MyQueue
Policy                                : {"Version":"2012-10-17",		 	 	 "Id":"arn:aws:sqs:us-east-1:80398EXAMPLE:MyQueue/SQSDefaultPolicy","Statement":[{"Sid":"Sid14
                                        495134224EX","Effect":"Allow","Principal":{"AWS":"*"},"Action":"SQS:SendMessage","Resource":"arn:aws:sqs:us-east-1:80
                                        398EXAMPLE:MyQueue","Condition":{"ArnEquals":{"aws:SourceArn":"arn:aws:sns:us-east-1:80398EXAMPLE:MyTopic"}}},{"Sid":
                                        "SendMessagesFromMyQueue","Effect":"Allow","Principal":{"AWS":"80398EXAMPLE"},"Action":"SQS:SendMessage","Resource":"
                                        arn:aws:sqs:us-east-1:80398EXAMPLE:MyQueue"}]}
Attributes                            : {[MaximumMessageSize, 262144], [VisibilityTimeout, 30]}
```
+  Per i dettagli sull'API, vedere [GetQueueAttributes](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

### `Get-SQSQueueUrl`
<a name="sqs_GetQueueUrl_powershell_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `Get-SQSQueueUrl`

**Strumenti per PowerShell V5**  
**Esempio 1: questo esempio elenca l’URL della coda con il nome specificato.**  

```
Get-SQSQueueUrl -QueueName MyQueue
```
**Output:**  

```
https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue
```
+  Per i dettagli sull'API, vedere [GetQueueUrl](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

### `New-SQSQueue`
<a name="sqs_CreateQueue_powershell_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `New-SQSQueue`

**Strumenti per PowerShell V5**  
**Esempio 1: questo esempio crea una coda con il nome specificato.**  

```
New-SQSQueue -QueueName MyQueue
```
**Output:**  

```
https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue
```
+  Per i dettagli sull'API, vedere [CreateQueue](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

### `Receive-SQSMessage`
<a name="sqs_ReceiveMessage_powershell_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `Receive-SQSMessage`

**Strumenti per PowerShell V5**  
**Esempio 1: questo esempio elenca le informazioni per un massimo di 10 messaggi da ricevere per la coda specificata. Le informazioni conterranno i valori degli attributi del messaggio specificati, se esistenti.**  

```
Receive-SQSMessage -AttributeName SenderId, SentTimestamp -MessageAttributeName StudentName, StudentGrade -MessageCount 10 -QueueUrl https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue
```
**Output:**  

```
Attributes             : {[SenderId, AIDAIAZKMSNQ7TEXAMPLE], [SentTimestamp, 1451495923744]}
Body                   : Information about John Doe's grade.
MD5OfBody              : ea572796e3c231f974fe75d89EXAMPLE
MD5OfMessageAttributes : 48c1ee811f0fe7c4e88fbe0f5EXAMPLE
MessageAttributes      : {[StudentGrade, Amazon.SQS.Model.MessageAttributeValue], [StudentName, Amazon.SQS.Model.MessageAttributeValue]}
MessageId              : 53828c4b-631b-469b-8833-c093cEXAMPLE
ReceiptHandle          : AQEBpfGp...20Q5cg==
```
+  Per i dettagli sull'API, vedere [ReceiveMessage](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

### `Remove-SQSMessage`
<a name="sqs_DeleteMessage_powershell_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `Remove-SQSMessage`

**Strumenti per PowerShell V5**  
**Esempio 1: questo esempio elimina il messaggio con l’handle di ricezione specificato dalla coda specificata.**  

```
Remove-SQSMessage -QueueUrl https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue -ReceiptHandle AQEBd329...v6gl8Q==
```
+  Per i dettagli sull'API, vedere [DeleteMessage](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

### `Remove-SQSMessageBatch`
<a name="sqs_DeleteMessageBatch_powershell_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `Remove-SQSMessageBatch`

**Strumenti per PowerShell V5**  
**Esempio 1: questo esempio elimina 2 messaggi con gli handle di ricezione specificati dalla coda specificata.**  

```
$deleteMessageRequest1 = New-Object Amazon.SQS.Model.DeleteMessageBatchRequestEntry
$deleteMessageRequest1.Id = "Request1"
$deleteMessageRequest1.ReceiptHandle = "AQEBX2g4...wtJSQg=="

$deleteMessageRequest2 = New-Object Amazon.SQS.Model.DeleteMessageBatchRequestEntry
$deleteMessageRequest2.Id = "Request2"
$deleteMessageRequest2.ReceiptHandle = "AQEBqOVY...KTsLYg=="

Remove-SQSMessageBatch -QueueUrl https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue -Entry $deleteMessageRequest1, $deleteMessageRequest2
```
**Output:**  

```
Failed    Successful                                                                    
------    ----------                                                                    
{}        {Request1, Request2}
```
+  Per i dettagli sull'API, vedere [DeleteMessageBatch](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

### `Remove-SQSPermission`
<a name="sqs_RemovePermission_powershell_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `Remove-SQSPermission`

**Strumenti per PowerShell V5**  
**Esempio 1: questo esempio rimuove le impostazioni delle autorizzazioni con l’etichetta specificata dalla coda specificata.**  

```
Remove-SQSPermission -Label SendMessagesFromMyQueue -QueueUrl https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue
```
+  Per i dettagli sull'API, vedere [RemovePermission](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

### `Remove-SQSQueue`
<a name="sqs_DeleteQueue_powershell_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `Remove-SQSQueue`

**Strumenti per PowerShell V5**  
**Esempio 1: questo esempio elimina la coda specificata.**  

```
Remove-SQSQueue -QueueUrl https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue
```
+  Per i dettagli sull'API, vedere [DeleteQueue](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

### `Send-SQSMessage`
<a name="sqs_SendMessage_powershell_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `Send-SQSMessage`

**Strumenti per PowerShell V5**  
**Esempio 1: questo esempio invia un messaggio con gli attributi e il corpo del messaggio specificati alla coda specificata con un ritardo di consegna del messaggio di 10 secondi.**  

```
$cityAttributeValue = New-Object Amazon.SQS.Model.MessageAttributeValue
$cityAttributeValue.DataType = "String"
$cityAttributeValue.StringValue = "AnyCity"

$populationAttributeValue = New-Object Amazon.SQS.Model.MessageAttributeValue
$populationAttributeValue.DataType = "Number"
$populationAttributeValue.StringValue = "1250800"

$messageAttributes = New-Object System.Collections.Hashtable
$messageAttributes.Add("City", $cityAttributeValue)
$messageAttributes.Add("Population", $populationAttributeValue)

Send-SQSMessage -DelayInSeconds 10 -MessageAttributes $messageAttributes -MessageBody "Information about the largest city in Any Region." -QueueUrl https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue
```
**Output:**  

```
MD5OfMessageAttributes              MD5OfMessageBody                    MessageId                                          
----------------------              ----------------                    ---------                                          
1d3e51347bc042efbdf6dda31EXAMPLE    51b0a3256d59467f973009b73EXAMPLE    c35fed8f-c739-4d0c-818b-1820eEXAMPLE
```
+  Per i dettagli sull'API, vedere [SendMessage](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

### `Send-SQSMessageBatch`
<a name="sqs_SendMessageBatch_powershell_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `Send-SQSMessageBatch`

**Strumenti per PowerShell V5**  
**Esempio 1: questo esempio invia 2 messaggi con gli attributi e i corpi dei messaggi specificati alla coda specificata. La distribuzione viene ritardata di 15 secondi per il primo messaggio e di 10 secondi per il secondo messaggio.**  

```
$student1NameAttributeValue = New-Object Amazon.SQS.Model.MessageAttributeValue
$student1NameAttributeValue.DataType = "String"
$student1NameAttributeValue.StringValue = "John Doe"

$student1GradeAttributeValue = New-Object Amazon.SQS.Model.MessageAttributeValue
$student1GradeAttributeValue.DataType = "Number"
$student1GradeAttributeValue.StringValue = "89"

$student2NameAttributeValue = New-Object Amazon.SQS.Model.MessageAttributeValue
$student2NameAttributeValue.DataType = "String"
$student2NameAttributeValue.StringValue = "Jane Doe"

$student2GradeAttributeValue = New-Object Amazon.SQS.Model.MessageAttributeValue
$student2GradeAttributeValue.DataType = "Number"
$student2GradeAttributeValue.StringValue = "93"

$message1 = New-Object Amazon.SQS.Model.SendMessageBatchRequestEntry 
$message1.DelaySeconds = 15
$message1.Id = "FirstMessage"
$message1.MessageAttributes.Add("StudentName", $student1NameAttributeValue)
$message1.MessageAttributes.Add("StudentGrade", $student1GradeAttributeValue)
$message1.MessageBody = "Information about John Doe's grade."

$message2 = New-Object Amazon.SQS.Model.SendMessageBatchRequestEntry 
$message2.DelaySeconds = 10
$message2.Id = "SecondMessage"
$message2.MessageAttributes.Add("StudentName", $student2NameAttributeValue)
$message2.MessageAttributes.Add("StudentGrade", $student2GradeAttributeValue)
$message2.MessageBody = "Information about Jane Doe's grade."

Send-SQSMessageBatch -QueueUrl https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue -Entry $message1, $message2
```
**Output:**  

```
Failed    Successful                                                                    
------    ----------                                                                    
{}        {FirstMessage, SecondMessage}
```
+  Per i dettagli sull'API, vedere [SendMessageBatch](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 

### `Set-SQSQueueAttribute`
<a name="sqs_SetQueueAttributes_powershell_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `Set-SQSQueueAttribute`

**Strumenti per PowerShell V5**  
**Esempio 1: questo esempio mostra come impostare una policy per sottoscrivere una coda a un argomento SNS. Quando si pubblica un messaggio in un argomento, viene inviato un messaggio a ogni coda sottoscritta.**  

```
# create the queue and topic to be associated
$qurl = New-SQSQueue -QueueName "myQueue"
$topicarn = New-SNSTopic -Name "myTopic"

# get the queue ARN to inject into the policy; it will be returned
# in the output's QueueARN member but we need to put it into a variable
# so text expansion in the policy string takes effect
$qarn = (Get-SQSQueueAttribute -QueueUrl $qurl -AttributeName "QueueArn").QueueARN

# construct the policy and inject arns
$policy = @"
{
  "Version":"2012-10-17",		 	 	 
  "Id": "$qarn/SQSPOLICY",
  "Statement": [
      {
      "Sid": "1",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "SQS:SendMessage",
      "Resource": "$qarn",
      "Condition": {
        "ArnEquals": {
          "aws:SourceArn": "$topicarn"
          }
      }
    }
  ]
}
"@

# set the policy
Set-SQSQueueAttribute -QueueUrl $qurl -Attribute @{ Policy=$policy }
```
**Esempio 2: questo esempio imposta gli attributi specificati della coda specificata.**  

```
Set-SQSQueueAttribute -Attribute @{"DelaySeconds" = "10"; "MaximumMessageSize" = "131072"} -QueueUrl https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue
```
+  Per i dettagli sull'API, vedere [SetQueueAttributes](https://docs.aws.amazon.com/powershell/v5/reference)in *AWS Strumenti per PowerShell Cmdlet Reference (*V5). 