

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à.

# Utilizzo di `UpdateDocument` con una CLI
<a name="example_ssm_UpdateDocument_section"></a>

I seguenti esempi di codice mostrano come usare `UpdateDocument`.

------
#### [ CLI ]

**AWS CLI**  
**Per creare una nuova versione di un documento**  
L’esempio seguente `update-document` crea una nuova versione di un documento quando viene eseguito su un computer Windows. Il documento specificato da `--document` deve essere in formato JSON. Nota che `file://` deve essere referenziato seguito dal percorso del file di contenuto. A causa di `$` all’inizio del parametro `--document-version`, in Windows è necessario racchiudere il valore tra virgolette doppie. Su Linux, macOS o in un PowerShell prompt, è necessario racchiudere il valore tra virgolette singole.  
Versione Windows.  

```
aws ssm update-document \
    --name {{"RunShellScript"}} \
    --content {{"file://RunShellScript.json"}} \
    --document-version {{"$LATEST"}}
```
Linux/Mac versione.  

```
aws ssm update-document \
    --name {{"RunShellScript"}} \
    --content {{"file://RunShellScript.json"}} \
    --document-version '{{$LATEST}}'
```
Contenuto di `RunShellScript.json`:  

```
{
    "schemaVersion": "2.0",
    "description": "Run an updated script",
    "parameters": {
        "commands": {
            "type": "StringList",
            "description": "(Required) Specify a shell script or a command to run."
        }
    },
    "mainSteps": [
        {
            "action": "aws:runShellScript",
            "name": "runShellScript",
            "inputs": {
                "runCommand": "{{ commands }}"
            }
        }
    ]
}
```
Output:  

```
{
    "DocumentDescription": {
        "Status": "Updating",
        "Hash": "f775e5df4904c6fa46686c4722fae9de1950dace25cd9608ff8d622046b68d9b",
        "Name": "RunShellScript",
        "Parameters": [
            {
                "Type": "StringList",
                "Name": "commands",
                "Description": "(Required) Specify a shell script or a command to run."
            }
        ],
        "DocumentType": "Command",
        "PlatformTypes": [
            "Linux"
        ],
        "DocumentVersion": "2",
        "HashType": "Sha256",
        "CreatedDate": 1487899655.152,
        "Owner": "123456789012",
        "SchemaVersion": "2.0",
        "DefaultVersion": "1",
        "LatestVersion": "2",
        "Description": "Run an updated script"
    }
}
```
Per ulteriori informazioni, consulta [Documenti di AWS Systems Manager](https://docs.aws.amazon.com/systems-manager/latest/userguide/documents.html) nella *Guida per l’utente di AWS Systems Manager*.  
+  Per i dettagli sull'API, vedi [UpdateDocument](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ssm/update-document.html) nel *AWS CLI Riferimento al comando*. 

------
#### [ PowerShell ]

**Strumenti per PowerShell V4**  
**Esempio 1: questo esempio crea una nuova versione di un documento con il contenuto aggiornato del file json specificato. Il documento deve essere in formato JSON. È possibile ottenere la versione del documento con»Get-SSMDocumentVersionListcmdlet».**  

```
Update-SSMDocument -Name RunShellScript -DocumentVersion "1" -Content (Get-Content -Raw "c:\temp\RunShellScript.json")
```
**Output:**  

```
CreatedDate     : 3/1/2017 2:59:17 AM
DefaultVersion  : 1
Description     : Run an updated script
DocumentType    : Command
DocumentVersion : 2
Hash            : 1d5ce820e999ff051eb4841ed887593daf77120fd76cae0d18a53cc42e4e22c1
HashType        : Sha256
LatestVersion   : 2
Name            : RunShellScript
Owner           : 809632081692
Parameters      : {commands}
PlatformTypes   : {Linux}
SchemaVersion   : 2.0
Sha1            :
Status          : Updating
```
+  Per informazioni dettagliate sull'API, vedere [UpdateDocument](https://docs.aws.amazon.com/powershell/v4/reference) nel *AWS Strumenti per PowerShell Riferimento al cmdlet (V4)*. 

**Strumenti per PowerShell V5**  
**Esempio 1: questo esempio crea una nuova versione di un documento con il contenuto aggiornato del file json specificato. Il documento deve essere in formato JSON. È possibile ottenere la versione del documento con»Get-SSMDocumentVersionListcmdlet».**  

```
Update-SSMDocument -Name RunShellScript -DocumentVersion "1" -Content (Get-Content -Raw "c:\temp\RunShellScript.json")
```
**Output:**  

```
CreatedDate     : 3/1/2017 2:59:17 AM
DefaultVersion  : 1
Description     : Run an updated script
DocumentType    : Command
DocumentVersion : 2
Hash            : 1d5ce820e999ff051eb4841ed887593daf77120fd76cae0d18a53cc42e4e22c1
HashType        : Sha256
LatestVersion   : 2
Name            : RunShellScript
Owner           : 809632081692
Parameters      : {commands}
PlatformTypes   : {Linux}
SchemaVersion   : 2.0
Sha1            :
Status          : Updating
```
+  Per informazioni dettagliate sull'API, vedere [UpdateDocument](https://docs.aws.amazon.com/powershell/v5/reference) nel *AWS Strumenti per PowerShell Riferimento al cmdlet (V5)*. 

------

Per un elenco completo di AWS Guide per sviluppatori SDK ed esempi di codice, consulta [L'utilizzo di questo servizio con un AWS SDK](sdk-general-information-section.md). Questo argomento include anche informazioni su come iniziare e dettagli sulle versioni precedenti dell’SDK.