

のバージョン 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)

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# Tools for PowerShell V5 を使用した Systems Manager の例
<a name="powershell_ssm_code_examples"></a>

次のコード例は、Systems Manager で AWS Tools for PowerShell V5 を使用してアクションを実行し、一般的なシナリオを実装する方法を示しています。

*アクション*はより大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。アクションは個々のサービス機能を呼び出す方法を示していますが、コンテキスト内のアクションは、関連するシナリオで確認できます。

各例には完全なソースコードへのリンクが含まれており、コードの設定方法と実行方法に関する手順を確認できます。

**Topics**
+ [アクション](#actions)

## アクション
<a name="actions"></a>

### `Add-SSMResourceTag`
<a name="ssm_AddTagsToResource_powershell_topic"></a>

次のコード例は、`Add-SSMResourceTag` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、新しいタグを使用してメンテナンスウィンドウを更新します。コマンドが成功した場合、出力はありません。この例で使用される構文には、PowerShell バージョン 3 以降が必要です。**  

```
$option1 = @{Key="Stack";Value=@("Production")}
Add-SSMResourceTag -ResourceId "mw-03eb9db42890fb82d" -ResourceType "MaintenanceWindow" -Tag $option1
```
**例 2: PowerShell バージョン 2 では、New-Object を使用して各タグを作成する必要があります。コマンドが成功した場合、出力はありません。**  

```
$tag1 = New-Object Amazon.SimpleSystemsManagement.Model.Tag
$tag1.Key = "Stack"
$tag1.Value = "Production"
		
Add-SSMResourceTag -ResourceId "mw-03eb9db42890fb82d" -ResourceType "MaintenanceWindow" -Tag $tag1
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[AddTagsToResource](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

### `Edit-SSMDocumentPermission`
<a name="ssm_ModifyDocumentPermission_powershell_topic"></a>

次のコード例は、`Edit-SSMDocumentPermission` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、ドキュメントのすべてのアカウントに「共有」アクセス許可を追加します。コマンドが成功した場合、出力はありません。**  

```
Edit-SSMDocumentPermission -Name "RunShellScript" -PermissionType "Share" -AccountIdsToAdd all
```
**例 2: この例では、ドキュメントの特定のアカウントに「共有」アクセス許可を追加します。コマンドが成功した場合、出力はありません。**  

```
Edit-SSMDocumentPermission -Name "RunShellScriptNew" -PermissionType "Share" -AccountIdsToAdd "123456789012"
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[ModifyDocumentPermission](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMActivation`
<a name="ssm_DescribeActivations_powershell_topic"></a>

次のコード例は、`Get-SSMActivation` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、アカウントのアクティベーションに関する詳細情報を示します。**  

```
Get-SSMActivation
```
**出力:**  

```
ActivationId        : 08e51e79-1e36-446c-8e63-9458569c1363
CreatedDate         : 3/1/2017 12:01:51 AM
DefaultInstanceName : MyWebServers
Description         :
ExpirationDate      : 3/2/2017 12:01:51 AM
Expired             : False
IamRole             : AutomationRole
RegistrationLimit   : 10
RegistrationsCount  : 0
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeActivations](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMAssociation`
<a name="ssm_DescribeAssociation_powershell_topic"></a>

次のコード例は、`Get-SSMAssociation` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インスタンスとドキュメントの関連付けを記述します。**  

```
Get-SSMAssociation -InstanceId "i-0000293ffd8c57862" -Name "AWS-UpdateSSMAgent"
```
**出力:**  

```
Name                  : AWS-UpdateSSMAgent
InstanceId            : i-0000293ffd8c57862
Date                  : 2/23/2017 6:55:22 PM
Status.Name           : Pending
Status.Date           : 2/20/2015 8:31:11 AM
Status.Message        : temp_status_change
Status.AdditionalInfo : Additional-Config-Needed
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeAssociation](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMAssociationExecution`
<a name="ssm_DescribeAssociationExecutions_powershell_topic"></a>

次のコード例は、`Get-SSMAssociationExecution` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、指定された関連付け ID の実行を返します。**  

```
Get-SSMAssociationExecution -AssociationId 123a45a0-c678-9012-3456-78901234db5e
```
**出力:**  

```
AssociationId         : 123a45a0-c678-9012-3456-78901234db5e
AssociationVersion    : 2
CreatedTime           : 3/2/2019 8:53:29 AM
DetailedStatus        :
ExecutionId           : 123a45a0-c678-9012-3456-78901234db5e
LastExecutionDate     : 1/1/0001 12:00:00 AM
ResourceCountByStatus : {Success=4}
Status                : Success
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeAssociationExecutions](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMAssociationExecutionTarget`
<a name="ssm_DescribeAssociationExecutionTargets_powershell_topic"></a>

次のコード例は、`Get-SSMAssociationExecutionTarget` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、関連付けの実行ターゲットの一部であるリソース ID とその実行ステータスを表示します。**  

```
Get-SSMAssociationExecutionTarget -AssociationId 123a45a0-c678-9012-3456-78901234db5e -ExecutionId 123a45a0-c678-9012-3456-78901234db5e | Select-Object ResourceId, Status
```
**出力:**  

```
ResourceId           Status
----------           ------
i-0b1b2a3456f7a890b  Success
i-01c12a45d6fc7a89f  Success
i-0a1caf234f56d7dc8  Success
i-012a3fd45af6dbcfe  Failed
i-0ddc1df23c4a5fb67  Success
```
**例 2: このコマンドは、コマンドドキュメントが関連付けられている昨日以降の特定のオートメーションにおける、特定の実行をチェックします。さらに、関連付けの実行が失敗したかどうかを確認し、失敗した場合は、実行のコマンド呼び出しの詳細情報とインスタンス ID が表示されます。**  

```
$AssociationExecution= Get-SSMAssociationExecutionTarget -AssociationId 1c234567-890f-1aca-a234-5a678d901cb0 -ExecutionId 12345ca12-3456-2345-2b45-23456789012 | 
    Where-Object {$_.LastExecutionDate -gt (Get-Date -Hour 00 -Minute 00).AddDays(-1)} 

foreach ($execution in $AssociationExecution) {
    if($execution.Status -ne 'Success'){
        Write-Output "There was an issue executing the association $($execution.AssociationId) on $($execution.ResourceId)"
        Get-SSMCommandInvocation -CommandId $execution.OutputSource.OutputSourceId -Detail:$true | Select-Object -ExpandProperty CommandPlugins
    }
}
```
**出力:**  

```
There was an issue executing the association 1c234567-890f-1aca-a234-5a678d901cb0 on i-0a1caf234f56d7dc8


Name                   : aws:runPowerShellScript
Output                 : 
                         ----------ERROR-------
                         failed to run commands: exit status 1
OutputS3BucketName     : 
OutputS3KeyPrefix      : 
OutputS3Region         : eu-west-1
ResponseCode           : 1
ResponseFinishDateTime : 5/29/2019 11:04:49 AM
ResponseStartDateTime  : 5/29/2019 11:04:49 AM
StandardErrorUrl       : 
StandardOutputUrl      : 
Status                 : Failed
StatusDetails          : Failed
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeAssociationExecutionTargets](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMAssociationList`
<a name="ssm_ListAssociations_powershell_topic"></a>

次のコード例は、`Get-SSMAssociationList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インスタンスのすべての関連付けを一覧表示します。この例で使用される構文には、PowerShell バージョン 3 以降が必要です。**  

```
$filter1 = @{Key="InstanceId";Value=@("i-0000293ffd8c57862")}
Get-SSMAssociationList -AssociationFilterList $filter1
```
**出力:**  

```
AssociationId      : d8617c07-2079-4c18-9847-1655fc2698b0
DocumentVersion    :
InstanceId         : i-0000293ffd8c57862
LastExecutionDate  : 2/20/2015 8:31:11 AM
Name               : AWS-UpdateSSMAgent
Overview           : Amazon.SimpleSystemsManagement.Model.AssociationOverview
ScheduleExpression :
Targets            : {InstanceIds}
```
**例 2: この例では、設定ドキュメントのすべての関連付けを一覧表示します。この例で使用される構文には、PowerShell バージョン 3 以降が必要です。**  

```
$filter2 = @{Key="Name";Value=@("AWS-UpdateSSMAgent")}
Get-SSMAssociationList -AssociationFilterList $filter2
```
**出力:**  

```
AssociationId      : d8617c07-2079-4c18-9847-1655fc2698b0
DocumentVersion    :
InstanceId         : i-0000293ffd8c57862
LastExecutionDate  : 2/20/2015 8:31:11 AM
Name               : AWS-UpdateSSMAgent
Overview           : Amazon.SimpleSystemsManagement.Model.AssociationOverview
ScheduleExpression :
Targets            : {InstanceIds}
```
**例 3: PowerShell バージョン 2 では、New-Object を使用して各フィルターを作成する必要があります。**  

```
$filter1 = New-Object Amazon.SimpleSystemsManagement.Model.AssociationFilter
$filter1.Key = "InstanceId"
$filter1.Value = "i-0000293ffd8c57862"

Get-SSMAssociationList -AssociationFilterList $filter1
```
**出力:**  

```
AssociationId      : d8617c07-2079-4c18-9847-1655fc2698b0
DocumentVersion    :
InstanceId         : i-0000293ffd8c57862
LastExecutionDate  : 2/20/2015 8:31:11 AM
Name               : AWS-UpdateSSMAgent
Overview           : Amazon.SimpleSystemsManagement.Model.AssociationOverview
ScheduleExpression :
Targets            : {InstanceIds}
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[ListAssociations](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMAssociationVersionList`
<a name="ssm_ListAssociationVersions_powershell_topic"></a>

次のコード例は、`Get-SSMAssociationVersionList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、指定された関連付けのすべてのバージョンを取得します。**  

```
Get-SSMAssociationVersionList -AssociationId 123a45a0-c678-9012-3456-78901234db5e
```
**出力:**  

```
AssociationId      : 123a45a0-c678-9012-3456-78901234db5e
AssociationName    :
AssociationVersion : 2
ComplianceSeverity :
CreatedDate        : 3/12/2019 9:21:01 AM
DocumentVersion    :
MaxConcurrency     :
MaxErrors          :
Name               : AWS-GatherSoftwareInventory
OutputLocation     :
Parameters         : {}
ScheduleExpression :
Targets            : {InstanceIds}

AssociationId      : 123a45a0-c678-9012-3456-78901234db5e
AssociationName    : test-case-1234567890
AssociationVersion : 1
ComplianceSeverity :
CreatedDate        : 3/2/2019 8:53:29 AM
DocumentVersion    :
MaxConcurrency     :
MaxErrors          :
Name               : AWS-GatherSoftwareInventory
OutputLocation     :
Parameters         : {}
ScheduleExpression : rate(30minutes)
Targets            : {InstanceIds}
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[ListAssociationVersions](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMAutomationExecution`
<a name="ssm_GetAutomationExecution_powershell_topic"></a>

次のコード例は、`Get-SSMAutomationExecution` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、オートメーションの実行に関する詳細を表示します。**  

```
Get-SSMAutomationExecution -AutomationExecutionId "4105a4fc-f944-11e6-9d32-8fb2db27a909"
```
**出力:**  

```
AutomationExecutionId     : 4105a4fc-f944-11e6-9d32-8fb2db27a909
AutomationExecutionStatus : Failed
DocumentName              : AWS-UpdateLinuxAmi
DocumentVersion           : 1
ExecutionEndTime          : 2/22/2017 9:17:08 PM
ExecutionStartTime        : 2/22/2017 9:17:02 PM
FailureMessage            : Step launchInstance failed maximum allowed times. You are not authorized to perform this operation. Encoded
                            authorization failure message: B_V2QyyN7NhSZQYpmVzpEc4oSnj2GLTNYnXUHsTbqJkNMoDgubmbtthLmZyaiUYekORIrA42-fv1x-04q5Fjff6glh
                            Yb6TI5b0GQeeNrpwNvpDzmO-PSR1swlAbg9fdM9BcNjyrznspUkWpuKu9EC1Ou6v3OXU1KC9nZ7mPlWMFZNkSioQqpwWEvMw-GZktsQzm67qOhUhBNOLWYhbS
                            pkfiqzY-5nw3S0obx30fhd3EJa5O_-GjV_a0nFXQJa70ik40bFOrEh3MtCSbrQT6--DvFy_FQ8TKvkIXadyVskeJI84XOF5WmA60f1pi5GI08i-nRfZS6oDeU
                            gELBjjoFKD8s3L2aI0B6umWVxnQOjqhQRxwJ53b54sZJ2PW3v_mtg9-q0CK0ezS3xfh_y0ilaUGOAZG-xjQFuvU_JZedWpla3xi-MZsmblAifBI
                            (Service: AmazonEC2; Status Code: 403; Error Code: UnauthorizedOperation; Request ID:
                            6a002f94-ba37-43fd-99e6-39517715fce5)
Outputs                   : {[createImage.ImageId, Amazon.Runtime.Internal.Util.AlwaysSendList`1[System.String]]}
Parameters                : {[AutomationAssumeRole, Amazon.Runtime.Internal.Util.AlwaysSendList`1[System.String]], [InstanceIamRole,
                            Amazon.Runtime.Internal.Util.AlwaysSendList`1[System.String]], [SourceAmiId,
                            Amazon.Runtime.Internal.Util.AlwaysSendList`1[System.String]]}
StepExecutions            : {launchInstance, updateOSSoftware, stopInstance, createImage...}
```
**例 2: この例では、指定されたオートメーションの実行 ID におけるステップの詳細情報を一覧表示します。**  

```
Get-SSMAutomationExecution -AutomationExecutionId e1d2bad3-4567-8901-ae23-456c7c8901be | Select-Object -ExpandProperty StepExecutions | Select-Object StepName, Action, StepStatus, ValidNextSteps
```
**出力:**  

```
StepName                  Action                  StepStatus ValidNextSteps
--------                  ------                  ---------- --------------
LaunchInstance            aws:runInstances        Success    {OSCompatibilityCheck}
OSCompatibilityCheck      aws:runCommand          Success    {RunPreUpdateScript}
RunPreUpdateScript        aws:runCommand          Success    {UpdateEC2Config}
UpdateEC2Config           aws:runCommand          Cancelled  {}
UpdateSSMAgent            aws:runCommand          Pending    {}
UpdateAWSPVDriver         aws:runCommand          Pending    {}
UpdateAWSEnaNetworkDriver aws:runCommand          Pending    {}
UpdateAWSNVMe             aws:runCommand          Pending    {}
InstallWindowsUpdates     aws:runCommand          Pending    {}
RunPostUpdateScript       aws:runCommand          Pending    {}
RunSysprepGeneralize      aws:runCommand          Pending    {}
StopInstance              aws:changeInstanceState Pending    {}
CreateImage               aws:createImage         Pending    {}
TerminateInstance         aws:changeInstanceState Pending    {}
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[GetAutomationExecution](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMAutomationExecutionList`
<a name="ssm_DescribeAutomationExecutions_powershell_topic"></a>

次のコード例は、`Get-SSMAutomationExecutionList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、アカウントに関連付けられているすべてのアクティブなオートメーションの実行と、終了したオートメーションの実行を記述します。**  

```
Get-SSMAutomationExecutionList
```
**出力:**  

```
AutomationExecutionId     : 4105a4fc-f944-11e6-9d32-8fb2db27a909
AutomationExecutionStatus : Failed
DocumentName              : AWS-UpdateLinuxAmi
DocumentVersion           : 1
ExecutedBy                : admin
ExecutionEndTime          : 2/22/2017 9:17:08 PM
ExecutionStartTime        : 2/22/2017 9:17:02 PM
LogFile                   :
Outputs                   : {[createImage.ImageId, Amazon.Runtime.Internal.Util.AlwaysSendList`1[System.String]]}
```
**例 2: この例では、AutomationExecutionStatus の「Success」以外の実行について、ExecutionID、ドキュメント、実行開始/終了タイムスタンプを表示します。**  

```
Get-SSMAutomationExecutionList | Where-Object AutomationExecutionStatus -ne "Success" | Select-Object AutomationExecutionId, DocumentName, AutomationExecutionStatus, ExecutionStartTime, ExecutionEndTime | Format-Table -AutoSize
```
**出力:**  

```
AutomationExecutionId                DocumentName                            AutomationExecutionStatus ExecutionStartTime   ExecutionEndTime
---------------------                ------------                            ------------------------- ------------------   ----------------
e1d2bad3-4567-8901-ae23-456c7c8901be AWS-UpdateWindowsAmi                    Cancelled                 4/16/2019 5:37:04 AM 4/16/2019 5:47:29 AM
61234567-a7f8-90e1-2b34-567b8bf9012c Fixed-UpdateAmi                         Cancelled                 4/16/2019 5:33:04 AM 4/16/2019 5:40:15 AM
91234d56-7e89-0ac1-2aee-34ea5d6a7c89 AWS-UpdateWindowsAmi                    Failed                    4/16/2019 5:22:46 AM 4/16/2019 5:27:29 AM
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeAutomationExecutions](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

### `Get-SSMAutomationStepExecution`
<a name="ssm_DescribeAutomationStepExecutions_powershell_topic"></a>

次のコード例は、`Get-SSMAutomationStepExecution` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、オートメーションワークフローにおけるすべてのアクティブなステップの実行と、終了したステップの実行に関する情報を表示します。**  

```
Get-SSMAutomationStepExecution -AutomationExecutionId e1d2bad3-4567-8901-ae23-456c7c8901be | Select-Object StepName, Action, StepStatus
```
**出力:**  

```
StepName                  Action                  StepStatus
--------                  ------                  ----------
LaunchInstance            aws:runInstances        Success
OSCompatibilityCheck      aws:runCommand          Success
RunPreUpdateScript        aws:runCommand          Success
UpdateEC2Config           aws:runCommand          Cancelled
UpdateSSMAgent            aws:runCommand          Pending
UpdateAWSPVDriver         aws:runCommand          Pending
UpdateAWSEnaNetworkDriver aws:runCommand          Pending
UpdateAWSNVMe             aws:runCommand          Pending
InstallWindowsUpdates     aws:runCommand          Pending
RunPostUpdateScript       aws:runCommand          Pending
RunSysprepGeneralize      aws:runCommand          Pending
StopInstance              aws:changeInstanceState Pending
CreateImage               aws:createImage         Pending
TerminateInstance         aws:changeInstanceState Pending
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeAutomationStepExecutions](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMAvailablePatch`
<a name="ssm_DescribeAvailablePatches_powershell_topic"></a>

次のコード例は、`Get-SSMAvailablePatch` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、Windows Server 2012 で利用でき、MSRC 重要度が「緊急」のすべてのパッチを取得します。この例で使用される構文には、PowerShell バージョン 3 以降が必要です。**  

```
$filter1 = @{Key="PRODUCT";Values=@("WindowsServer2012")}
$filter2 = @{Key="MSRC_SEVERITY";Values=@("Critical")}

Get-SSMAvailablePatch -Filter $filter1,$filter2
```
**出力:**  

```
Classification : SecurityUpdates
ContentUrl     : https://support.microsoft.com/en-us/kb/2727528
Description    : A security issue has been identified that could allow an unauthenticated remote attacker to compromise your system and gain control
                 over it. You can help protect your system by installing this update from Microsoft. After you install this update, you may have to
                 restart your system.
Id             : 1eb507be-2040-4eeb-803d-abc55700b715
KbNumber       : KB2727528
Language       : All
MsrcNumber     : MS12-072
MsrcSeverity   : Critical
Product        : WindowsServer2012
ProductFamily  : Windows
ReleaseDate    : 11/13/2012 6:00:00 PM
Title          : Security Update for Windows Server 2012 (KB2727528)
Vendor         : Microsoft
...
```
**例 2: PowerShell バージョン 2 では、New-Object を使用して各フィルターを作成する必要があります。**  

```
$filter1 = New-Object Amazon.SimpleSystemsManagement.Model.PatchOrchestratorFilter
$filter1.Key = "PRODUCT"
$filter1.Values = "WindowsServer2012"
$filter2 = New-Object Amazon.SimpleSystemsManagement.Model.PatchOrchestratorFilter
$filter2.Key = "MSRC_SEVERITY"
$filter2.Values = "Critical"

Get-SSMAvailablePatch -Filter $filter1,$filter2
```
**例 3: この例では、過去 20 日間にリリースされた、Windows Server 2019 に一致する製品に適用されるすべてのパッチの更新情報を取得します。**  

```
Get-SSMAvailablePatch | Where-Object ReleaseDate -ge (Get-Date).AddDays(-20) | Where-Object Product -eq "WindowsServer2019" | Select-Object ReleaseDate, Product, Title
```
**出力:**  

```
ReleaseDate         Product           Title
-----------         -------           -----
4/9/2019 5:00:12 PM WindowsServer2019 2019-04 Security Update for Adobe Flash Player for Windows Server 2019 for x64-based Systems (KB4493478)
4/9/2019 5:00:06 PM WindowsServer2019 2019-04 Cumulative Update for Windows Server 2019 for x64-based Systems (KB4493509)
4/2/2019 5:00:06 PM WindowsServer2019 2019-03 Servicing Stack Update for Windows Server 2019 for x64-based Systems (KB4493510)
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeAvailablePatches](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMCommand`
<a name="ssm_ListCommands_powershell_topic"></a>

次のコード例は、`Get-SSMCommand` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、リクエストされたすべてのコマンドを一覧表示します。**  

```
Get-SSMCommand
```
**出力:**  

```
CommandId          : 4b75a163-d39a-4d97-87c9-98ae52c6be35
Comment            : Apply association with id at update time: 4cc73e42-d5ae-4879-84f8-57e09c0efcd0
CompletedCount     : 1
DocumentName       : AWS-RefreshAssociation
ErrorCount         : 0
ExpiresAfter       : 2/24/2017 3:19:08 AM
InstanceIds        : {i-0cb2b964d3e14fd9f}
MaxConcurrency     : 50
MaxErrors          : 0
NotificationConfig : Amazon.SimpleSystemsManagement.Model.NotificationConfig
OutputS3BucketName :
OutputS3KeyPrefix  :
OutputS3Region     :
Parameters         : {[associationIds, Amazon.Runtime.Internal.Util.AlwaysSendList`1[System.String]]}
RequestedDateTime  : 2/24/2017 3:18:08 AM
ServiceRole        :
Status             : Success
StatusDetails      : Success
TargetCount        : 1
Targets            : {}
```
**例 2: この例では、特定のコマンドのステータスを取得します。**  

```
Get-SSMCommand -CommandId "4b75a163-d39a-4d97-87c9-98ae52c6be35"
```
**例 3: この例では、2019-04-01T00:00:00Z より後に呼び出されたすべての SSM コマンドを取得します。 **  

```
Get-SSMCommand -Filter @{Key="InvokedAfter";Value="2019-04-01T00:00:00Z"} | Select-Object CommandId, DocumentName, Status, RequestedDateTime | Sort-Object -Property RequestedDateTime -Descending
```
**出力:**  

```
CommandId                            DocumentName               Status    RequestedDateTime
---------                            ------------               ------    -----------------
edb1b23e-456a-7adb-aef8-90e-012ac34f AWS-RunPowerShellScript    Cancelled 4/16/2019 5:45:23 AM
1a2dc3fb-4567-890d-a1ad-234b5d6bc7d9 AWS-ConfigureAWSPackage    Success   4/6/2019 9:19:42 AM
12c3456c-7e90-4f12-1232-1234f5b67893 KT-Retrieve-Cloud-Type-Win Failed    4/2/2019 4:13:07 AM
fe123b45-240c-4123-a2b3-234bdd567ecf AWS-RunInspecChecks        Failed    4/1/2019 2:27:31 PM
1eb23aa4-567d-4123-12a3-4c1c2ab34561 AWS-RunPowerShellScript    Success   4/1/2019 1:05:55 PM
1c2f3bb4-ee12-4bc1-1a23-12345eea123e AWS-RunInspecChecks        Failed    4/1/2019 11:13:09 AM
```
+  API の詳細については、「AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[ListCommands](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMCommandInvocation`
<a name="ssm_ListCommandInvocations_powershell_topic"></a>

次のコード例は、`Get-SSMCommandInvocation` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、コマンドのすべての呼び出しを一覧表示します。**  

```
Get-SSMCommandInvocation -CommandId "b8eac879-0541-439d-94ec-47a80d554f44" -Detail $true
```
**出力:**  

```
CommandId          : b8eac879-0541-439d-94ec-47a80d554f44
CommandPlugins     : {aws:runShellScript}
Comment            : IP config
DocumentName       : AWS-RunShellScript
InstanceId         : i-0cb2b964d3e14fd9f
InstanceName       :
NotificationConfig : Amazon.SimpleSystemsManagement.Model.NotificationConfig
RequestedDateTime  : 2/22/2017 8:13:16 PM
ServiceRole        :
StandardErrorUrl   :
StandardOutputUrl  :
Status             : Success
StatusDetails      : Success
TraceOutput        :
```
**例 2: この例では、コマンド ID e1eb2e3c-ed4c-5123-45c1-234f5612345f の呼び出し用の CommandPlugins を一覧表示します。**  

```
Get-SSMCommandInvocation -CommandId e1eb2e3c-ed4c-5123-45c1-234f5612345f -Detail:$true | Select-Object -ExpandProperty CommandPlugins
```
**出力:**  

```
Name                   : aws:runPowerShellScript
Output                 : Completed 17.7 KiB/17.7 KiB (40.1 KiB/s) with 1 file(s) remainingdownload: s3://dd-aess-r-ctmer/KUMO.png to ..\..\programdata\KUMO.png
                         kumo available

OutputS3BucketName     :
OutputS3KeyPrefix      :
OutputS3Region         : eu-west-1
ResponseCode           : 0
ResponseFinishDateTime : 4/3/2019 11:53:23 AM
ResponseStartDateTime  : 4/3/2019 11:53:21 AM
StandardErrorUrl       :
StandardOutputUrl      :
Status                 : Success
StatusDetails          : Success
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[ListCommandInvocations](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMCommandInvocationDetail`
<a name="ssm_GetCommandInvocation_powershell_topic"></a>

次のコード例は、`Get-SSMCommandInvocationDetail` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インスタンスで実行されたコマンドの詳細情報を表示します。**  

```
Get-SSMCommandInvocationDetail -InstanceId "i-0cb2b964d3e14fd9f" -CommandId "b8eac879-0541-439d-94ec-47a80d554f44"
```
**出力:**  

```
CommandId              : b8eac879-0541-439d-94ec-47a80d554f44
Comment                : IP config
DocumentName           : AWS-RunShellScript
ExecutionElapsedTime   : PT0.004S
ExecutionEndDateTime   : 2017-02-22T20:13:16.651Z
ExecutionStartDateTime : 2017-02-22T20:13:16.651Z
InstanceId             : i-0cb2b964d3e14fd9f
PluginName             : aws:runShellScript
ResponseCode           : 0
StandardErrorContent   :
StandardErrorUrl       :
StandardOutputContent  :
StandardOutputUrl      :
Status                 : Success
StatusDetails          : Success
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[GetCommandInvocation](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMComplianceItemList`
<a name="ssm_ListComplianceItems_powershell_topic"></a>

次のコード例は、`Get-SSMComplianceItemList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、任意のリソース ID とタイプのコンプライアンス項目リストを一覧表示し、コンプライアンスタイプを「関連付け」でフィルタリングします。**  

```
Get-SSMComplianceItemList -ResourceId i-1a2caf345f67d0dc2 -ResourceType ManagedInstance -Filter @{Key="ComplianceType";Values="Association"}
```
**出力:**  

```
ComplianceType   : Association
Details          : {[DocumentName, AWS-GatherSoftwareInventory], [DocumentVersion, 1]}
ExecutionSummary : Amazon.SimpleSystemsManagement.Model.ComplianceExecutionSummary
Id               : 123a45a1-c234-1234-1245-67891236db4e
ResourceId       : i-1a2caf345f67d0dc2
ResourceType     : ManagedInstance
Severity         : UNSPECIFIED
Status           : COMPLIANT
Title            :
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[ListComplianceItems](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMComplianceSummaryList`
<a name="ssm_ListComplianceSummaries_powershell_topic"></a>

次のコード例は、`Get-SSMComplianceSummaryList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、すべてのコンプライアンスタイプの準拠リソースと非準拠リソースの集計カウントを返します。**  

```
Get-SSMComplianceSummaryList
```
**出力:**  

```
ComplianceType CompliantSummary                                      NonCompliantSummary
-------------- ----------------                                      -------------------
FleetTotal     Amazon.SimpleSystemsManagement.Model.CompliantSummary Amazon.SimpleSystemsManagement.Model.NonCompliantSummary
Association    Amazon.SimpleSystemsManagement.Model.CompliantSummary Amazon.SimpleSystemsManagement.Model.NonCompliantSummary
Custom:InSpec  Amazon.SimpleSystemsManagement.Model.CompliantSummary Amazon.SimpleSystemsManagement.Model.NonCompliantSummary
Patch          Amazon.SimpleSystemsManagement.Model.CompliantSummary Amazon.SimpleSystemsManagement.Model.NonCompliantSummary
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[ListComplianceSummaries](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMConnectionStatus`
<a name="ssm_GetConnectionStatus_powershell_topic"></a>

次のコード例は、`Get-SSMConnectionStatus` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インスタンスが接続され、Session Manager 接続を受信する準備ができているかどうかを判断するため、インスタンスの Session Manager 接続ステータスを取得します。**  

```
Get-SSMConnectionStatus -Target i-0a1caf234f12d3dc4
```
**出力:**  

```
Status    Target
------    ------
Connected i-0a1caf234f12d3dc4
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[GetConnectionStatus](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMDefaultPatchBaseline`
<a name="ssm_GetDefaultPatchBaseline_powershell_topic"></a>

次のコード例は、`Get-SSMDefaultPatchBaseline` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、デフォルトのパッチベースラインを表示します。**  

```
Get-SSMDefaultPatchBaseline
```
**出力:**  

```
arn:aws:ssm:us-west-2:123456789012:patchbaseline/pb-04fb4ae6142167966
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[GetDefaultPatchBaseline](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMDeployablePatchSnapshotForInstance`
<a name="ssm_GetDeployablePatchSnapshotForInstance_powershell_topic"></a>

次のコード例は、`Get-SSMDeployablePatchSnapshotForInstance` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インスタンスで使用されるパッチベースラインの現在のスナップショットを表示します。このコマンドは、インスタンス認証情報を使用してインスタンスから実行する必要があります。この例では、インスタンス認証情報が使用されるようにするため、Credentials パラメータに `Amazon.Runtime.InstanceProfileAWSCredentials` オブジェクトを渡します。**  

```
$credentials = [Amazon.Runtime.InstanceProfileAWSCredentials]::new()
Get-SSMDeployablePatchSnapshotForInstance -SnapshotId "4681775b-098f-4435-a956-0ef33373ac11" -InstanceId "i-0cb2b964d3e14fd9f" -Credentials $credentials
```
**出力:**  

```
InstanceId          SnapshotDownloadUrl
----------          -------------------
i-0cb2b964d3e14fd9f https://patch-baseline-snapshot-us-west-2.s3-us-west-2.amazonaws.com/853d0d3db0f0cafe...1692/4681775b-098f-4435...
```
**例 2: この例は、完全な SnapshotDownloadUrl を取得する方法を示しています。このコマンドは、インスタンス認証情報を使用してインスタンスから実行する必要があります。この例では、インスタンス認証情報が使用されるようにするため PowerShell セッションが `Amazon.Runtime.InstanceProfileAWSCredentials` オブジェクトを使用するように設定しています。**  

```
Set-AWSCredential -Credential ([Amazon.Runtime.InstanceProfileAWSCredentials]::new())
(Get-SSMDeployablePatchSnapshotForInstance -SnapshotId "4681775b-098f-4435-a956-0ef33373ac11" -InstanceId "i-0cb2b964d3e14fd9f").SnapshotDownloadUrl
```
**出力:**  

```
https://patch-baseline-snapshot-us-west-2.s3-us-west-2.amazonaws.com/853d0d3db0f0cafe...
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[GetDeployablePatchSnapshotForInstance](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMDocument`
<a name="ssm_GetDocument_powershell_topic"></a>

次のコード例は、`Get-SSMDocument` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、ドキュメントのコンテンツを返します。**  

```
Get-SSMDocument -Name "RunShellScript"
```
**出力:**  

```
Content
-------
{...
```
**例 2: この例では、ドキュメントの完全なコンテンツを表示します。**  

```
(Get-SSMDocument -Name "RunShellScript").Content
{
   "schemaVersion":"2.0",
   "description":"Run an updated script",
   "parameters":{
      "commands":{
         "type":"StringList",
         "description":"(Required) Specify a shell script or a command to run.",
         "minItems":1,
         "displayType":"textarea"
      }
   },
   "mainSteps":[
      {
         "action":"aws:runShellScript",
         "name":"runShellScript",
         "inputs":{
            "commands":"{{ commands }}"
         }
      },
      {
         "action":"aws:runPowerShellScript",
         "name":"runPowerShellScript",
         "inputs":{
            "commands":"{{ commands }}"
         }
      }
   ]
}
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[GetDocument](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMDocumentDescription`
<a name="ssm_DescribeDocument_powershell_topic"></a>

次のコード例は、`Get-SSMDocumentDescription` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、ドキュメントに関する情報を返します。**  

```
Get-SSMDocumentDescription -Name "RunShellScript"
```
**出力:**  

```
CreatedDate     : 2/24/2017 5:25:13 AM
DefaultVersion  : 1
Description     : Run an updated script
DocumentType    : Command
DocumentVersion : 1
Hash            : f775e5df4904c6fa46686c4722fae9de1950dace25cd9608ff8d622046b68d9b
HashType        : Sha256
LatestVersion   : 1
Name            : RunShellScript
Owner           : 123456789012
Parameters      : {commands}
PlatformTypes   : {Linux}
SchemaVersion   : 2.0
Sha1            :
Status          : Active
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeDocument](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMDocumentList`
<a name="ssm_ListDocuments_powershell_topic"></a>

次のコード例は、`Get-SSMDocumentList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: アカウント内のすべての設定ドキュメントを一覧表示します。**  

```
Get-SSMDocumentList
```
**出力:**  

```
DocumentType    : Command
DocumentVersion : 1
Name            : AWS-ApplyPatchBaseline
Owner           : Amazon
PlatformTypes   : {Windows}
SchemaVersion   : 1.2

DocumentType    : Command
DocumentVersion : 1
Name            : AWS-ConfigureAWSPackage
Owner           : Amazon
PlatformTypes   : {Windows, Linux}
SchemaVersion   : 2.0

DocumentType    : Command
DocumentVersion : 1
Name            : AWS-ConfigureCloudWatch
Owner           : Amazon
PlatformTypes   : {Windows}
SchemaVersion   : 1.2
...
```
**例 2: この例では、名前が「プラットフォーム」と一致するすべてのオートメーションドキュメントを取得します。**  

```
Get-SSMDocumentList -DocumentFilterList @{Key="DocumentType";Value="Automation"} | Where-Object Name -Match "Platform"
```
**出力:**  

```
DocumentFormat  : JSON
DocumentType    : Automation
DocumentVersion : 7
Name            : KT-Get-Platform
Owner           : 987654123456
PlatformTypes   : {Windows, Linux}
SchemaVersion   : 0.3
Tags            : {}
TargetType      :
VersionName     :
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[ListDocuments](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMDocumentPermission`
<a name="ssm_DescribeDocumentPermission_powershell_topic"></a>

次のコード例は、`Get-SSMDocumentPermission` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、ドキュメントのすべてのバージョンを一覧表示します。**  

```
Get-SSMDocumentVersionList -Name "RunShellScript"
```
**出力:**  

```
CreatedDate          DocumentVersion IsDefaultVersion Name
-----------          --------------- ---------------- ----
2/24/2017 5:25:13 AM 1               True             RunShellScript
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeDocumentPermission](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

### `Get-SSMDocumentVersionList`
<a name="ssm_ListDocumentVersions_powershell_topic"></a>

次のコード例は、`Get-SSMDocumentVersionList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、ドキュメントのすべてのバージョンを一覧表示します。**  

```
Get-SSMDocumentVersionList -Name "AWS-UpdateSSMAgent"
```
**出力:**  

```
CreatedDate       : 6/1/2021 5:19:10 PM
DocumentFormat    : JSON
DocumentVersion   : 1
IsDefaultVersion  : True
Name              : AWS-UpdateSSMAgent
Status            : Active
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[ListDocumentVersions](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMEffectiveInstanceAssociationList`
<a name="ssm_DescribeEffectiveInstanceAssociations_powershell_topic"></a>

次のコード例は、`Get-SSMEffectiveInstanceAssociationList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インスタンスの有効な関連付けを記述します。**  

```
Get-SSMEffectiveInstanceAssociationList -InstanceId "i-0000293ffd8c57862" -MaxResult 5
```
**出力:**  

```
AssociationId                        Content
-------------                        -------
d8617c07-2079-4c18-9847-1655fc2698b0 {...
```
**例 2: この例では、インスタンスの有効な関連付けの内容を記述します。**  

```
(Get-SSMEffectiveInstanceAssociationList -InstanceId "i-0000293ffd8c57862" -MaxResult 5).Content
```
**出力:**  

```
{
    "schemaVersion": "1.2",
    "description": "Update the Amazon SSM Agent to the latest version or specified version.",
    "parameters": {
        "version": {
            "default": "",
            "description": "(Optional) A specific version of the Amazon SSM Agent to install. If not specified, the agen
t will be updated to the latest version.",
            "type": "String"
        },
        "allowDowngrade": {
            "default": "false",
            "description": "(Optional) Allow the Amazon SSM Agent service to be downgraded to an earlier version. If set
 to false, the service can be upgraded to newer versions only (default). If set to true, specify the earlier version.",
            "type": "String",
            "allowedValues": [
                "true",
                "false"
            ]
        }
    },
    "runtimeConfig": {
        "aws:updateSsmAgent": {
            "properties": [
                {
                "agentName": "amazon-ssm-agent",
                "source": "https://s3.{Region}.amazonaws.com/amazon-ssm-{Region}/ssm-agent-manifest.json",
                "allowDowngrade": "{{ allowDowngrade }}",
                "targetVersion": "{{ version }}"
                }
            ]
        }
    }
}
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeEffectiveInstanceAssociations](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMEffectivePatchesForPatchBaseline`
<a name="ssm_DescribeEffectivePatchesForPatchBaseline_powershell_topic"></a>

次のコード例は、`Get-SSMEffectivePatchesForPatchBaseline` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、すべてのパッチベースラインを一覧表示します。結果の最大表示件数は 1 です。**  

```
Get-SSMEffectivePatchesForPatchBaseline -BaselineId "pb-0a2f1059b670ebd31" -MaxResult 1
```
**出力:**  

```
Patch                                      PatchStatus
-----                                      -----------
Amazon.SimpleSystemsManagement.Model.Patch Amazon.SimpleSystemsManagement.Model.PatchStatus
```
**例 2: この例では、すべてのパッチベースラインのパッチステータスを表示します。結果の最大表示件数は 1 です。**  

```
(Get-SSMEffectivePatchesForPatchBaseline -BaselineId "pb-0a2f1059b670ebd31" -MaxResult 1).PatchStatus
```
**出力:**  

```
ApprovalDate          DeploymentStatus
------------          ----------------
12/21/2010 6:00:00 PM APPROVED
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeEffectivePatchesForPatchBaseline](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMInstanceAssociationsStatus`
<a name="ssm_DescribeInstanceAssociationsStatus_powershell_topic"></a>

次のコード例は、`Get-SSMInstanceAssociationsStatus` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インスタンスの関連付けの詳細情報を表示します。**  

```
Get-SSMInstanceAssociationsStatus -InstanceId "i-0000293ffd8c57862"
```
**出力:**  

```
AssociationId    : d8617c07-2079-4c18-9847-1655fc2698b0
DetailedStatus   : Pending
DocumentVersion  : 1
ErrorCode        :
ExecutionDate    : 2/20/2015 8:31:11 AM
ExecutionSummary : temp_status_change
InstanceId       : i-0000293ffd8c57862
Name             : AWS-UpdateSSMAgent
OutputUrl        :
Status           : Pending
```
**例 2: この例では、指定されたインスタンス ID におけるインスタンスの関連付けのステータスを確認し、それらの関連付けの実行ステータスを表示します。**  

```
Get-SSMInstanceAssociationsStatus -InstanceId i-012e3cb4df567e8aa | ForEach-Object {Get-SSMAssociationExecution -AssociationId .AssociationId}
```
**出力:**  

```
AssociationId         : 512a34a5-c678-1234-1234-12345678db9e
AssociationVersion    : 2
CreatedTime           : 3/2/2019 8:53:29 AM
DetailedStatus        :
ExecutionId           : 512a34a5-c678-1234-1234-12345678db9e
LastExecutionDate     : 1/1/0001 12:00:00 AM
ResourceCountByStatus : {Success=9}
Status                : Success
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeInstanceAssociationsStatus](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

### `Get-SSMInstanceInformation`
<a name="ssm_DescribeInstanceInformation_powershell_topic"></a>

次のコード例は、`Get-SSMInstanceInformation` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、各インスタンスの詳細情報を表示します。**  

```
Get-SSMInstanceInformation
```
**出力:**  

```
ActivationId                           :
AgentVersion                           : 2.0.672.0
AssociationOverview                    : Amazon.SimpleSystemsManagement.Model.InstanceAggregatedAssociationOverview
AssociationStatus                      : Success
ComputerName                           : ip-172-31-44-222.us-west-2.compute.internal
IamRole                                :
InstanceId                             : i-0cb2b964d3e14fd9f
IPAddress                              : 172.31.44.222
IsLatestVersion                        : True
LastAssociationExecutionDate           : 2/24/2017 3:18:09 AM
LastPingDateTime                       : 2/24/2017 3:35:03 AM
LastSuccessfulAssociationExecutionDate : 2/24/2017 3:18:09 AM
Name                                   :
PingStatus                             : ConnectionLost
PlatformName                           : Amazon Linux AMI
PlatformType                           : Linux
PlatformVersion                        : 2016.09
RegistrationDate                       : 1/1/0001 12:00:00 AM
ResourceType                           : EC2Instance
```
**例 2: この例では、-Filter パラメータを使用して、 `AgentVersion`の `us-east-1`を持つリージョン内の AWS Systems Manager インスタンスのみに結果をフィルタリングする方法を示します`2.2.800.0`。有効な -Filter キー値のリストは、InstanceInformation の API リファレンストピック (https://docs.aws.amazon.com/systems-manager/latest/APIReference/API\$1InstanceInformation.html\$1systemsmanager-Type-InstanceInformation-ActivationId) で確認できます。**  

```
$Filters = @{
    Key="AgentVersion"
    Values="2.2.800.0"
}
Get-SSMInstanceInformation -Region us-east-1 -Filter $Filters
```
**出力:**  

```
ActivationId                           : 
AgentVersion                           : 2.2.800.0
AssociationOverview                    : Amazon.SimpleSystemsManagement.Model.InstanceAggregatedAssociationOverview
AssociationStatus                      : Success
ComputerName                           : EXAMPLE-EXAMPLE.WORKGROUP
IamRole                                : 
InstanceId                             : i-EXAMPLEb0792d98ce
IPAddress                              : 10.0.0.01
IsLatestVersion                        : False
LastAssociationExecutionDate           : 8/16/2018 12:02:50 AM
LastPingDateTime                       : 8/16/2018 7:40:27 PM
LastSuccessfulAssociationExecutionDate : 8/16/2018 12:02:50 AM
Name                                   : 
PingStatus                             : Online
PlatformName                           : Microsoft Windows Server 2016 Datacenter
PlatformType                           : Windows
PlatformVersion                        : 10.0.14393
RegistrationDate                       : 1/1/0001 12:00:00 AM
ResourceType                           : EC2Instance

ActivationId                           : 
AgentVersion                           : 2.2.800.0
AssociationOverview                    : Amazon.SimpleSystemsManagement.Model.InstanceAggregatedAssociationOverview
AssociationStatus                      : Success
ComputerName                           : EXAMPLE-EXAMPLE.WORKGROUP
IamRole                                : 
InstanceId                             : i-EXAMPLEac7501d023
IPAddress                              : 10.0.0.02
IsLatestVersion                        : False
LastAssociationExecutionDate           : 8/16/2018 12:00:20 AM
LastPingDateTime                       : 8/16/2018 7:40:35 PM
LastSuccessfulAssociationExecutionDate : 8/16/2018 12:00:20 AM
Name                                   : 
PingStatus                             : Online
PlatformName                           : Microsoft Windows Server 2016 Datacenter
PlatformType                           : Windows
PlatformVersion                        : 10.0.14393
RegistrationDate                       : 1/1/0001 12:00:00 AM
ResourceType                           : EC2Instance
```
**例 3: この例では、-InstanceInformationFilterList パラメータを使用して、 `Windows`または `us-east-1``PlatformTypes`を持つリージョン内の AWS Systems Manager インスタンスのみに結果をフィルタリングする方法を示します`Linux`。有効な -InstanceInformationFilterList キー値のリストは、InstanceInformationFilter の API リファレンストピック (https://docs.aws.amazon.com/systems-manager/latest/APIReference/API\$1InstanceInformationFilter.html) で確認できます。**  

```
$Filters = @{
   Key="PlatformTypes"
   ValueSet=("Windows","Linux")
}
Get-SSMInstanceInformation -Region us-east-1 -InstanceInformationFilterList $Filters
```
**出力:**  

```
ActivationId                           : 
AgentVersion                           : 2.2.800.0
AssociationOverview                    : Amazon.SimpleSystemsManagement.Model.InstanceAggregatedAssociationOverview
AssociationStatus                      : Success
ComputerName                           : EXAMPLE-EXAMPLE.WORKGROUP
IamRole                                : 
InstanceId                             : i-EXAMPLEb0792d98ce
IPAddress                              : 10.0.0.27
IsLatestVersion                        : False
LastAssociationExecutionDate           : 8/16/2018 12:02:50 AM
LastPingDateTime                       : 8/16/2018 7:40:27 PM
LastSuccessfulAssociationExecutionDate : 8/16/2018 12:02:50 AM
Name                                   : 
PingStatus                             : Online
PlatformName                           : Ubuntu Server 18.04 LTS
PlatformType                           : Linux
PlatformVersion                        : 18.04
RegistrationDate                       : 1/1/0001 12:00:00 AM
ResourceType                           : EC2Instance

ActivationId                           : 
AgentVersion                           : 2.2.800.0
AssociationOverview                    : Amazon.SimpleSystemsManagement.Model.InstanceAggregatedAssociationOverview
AssociationStatus                      : Success
ComputerName                           : EXAMPLE-EXAMPLE.WORKGROUP
IamRole                                : 
InstanceId                             : i-EXAMPLEac7501d023
IPAddress                              : 10.0.0.100
IsLatestVersion                        : False
LastAssociationExecutionDate           : 8/16/2018 12:00:20 AM
LastPingDateTime                       : 8/16/2018 7:40:35 PM
LastSuccessfulAssociationExecutionDate : 8/16/2018 12:00:20 AM
Name                                   : 
PingStatus                             : Online
PlatformName                           : Microsoft Windows Server 2016 Datacenter
PlatformType                           : Windows
PlatformVersion                        : 10.0.14393
RegistrationDate                       : 1/1/0001 12:00:00 AM
ResourceType                           : EC2Instance
```
**例 4: この例では、ssm マネージドインスタンスを一覧表示し、InstanceId、PingStatus、LastPingDateTime、PlatformName を csv ファイルにエクスポートします。**  

```
Get-SSMInstanceInformation | Select-Object InstanceId, PingStatus, LastPingDateTime, PlatformName | Export-Csv Instance-details.csv -NoTypeInformation
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeInstanceInformation](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMInstancePatch`
<a name="ssm_DescribeInstancePatches_powershell_topic"></a>

次のコード例は、`Get-SSMInstancePatch` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インスタンスのパッチコンプライアンスの詳細を取得します。**  

```
Get-SSMInstancePatch -InstanceId "i-08ee91c0b17045407"
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeInstancePatches](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMInstancePatchState`
<a name="ssm_DescribeInstancePatchStates_powershell_topic"></a>

次のコード例は、`Get-SSMInstancePatchState` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インスタンスのパッチの概要状態を取得します。**  

```
Get-SSMInstancePatchState -InstanceId "i-08ee91c0b17045407"
```
**例 2: この例では、2 つのインスタンスにおけるパッチの概要状態を取得します。**  

```
Get-SSMInstancePatchState -InstanceId "i-08ee91c0b17045407","i-09a618aec652973a9"
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeInstancePatchStates](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMInstancePatchStatesForPatchGroup`
<a name="ssm_DescribeInstancePatchStatesForPatchGroup_powershell_topic"></a>

次のコード例は、`Get-SSMInstancePatchStatesForPatchGroup` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、パッチグループにおけるインスタンスごとのパッチの概要状態を取得します。**  

```
Get-SSMInstancePatchStatesForPatchGroup -PatchGroup "Production"
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeInstancePatchStatesForPatchGroup](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMInventory`
<a name="ssm_GetInventory_powershell_topic"></a>

次のコード例は、`Get-SSMInventory` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インベントリのカスタムメタデータを取得します。**  

```
Get-SSMInventory
```
**出力:**  

```
Data                                                                                  Id
----                                                                                  --
{[AWS:InstanceInformation, Amazon.SimpleSystemsManagement.Model.InventoryResultItem]} i-0cb2b964d3e14fd9f
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[GetInventory](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMInventoryEntriesList`
<a name="ssm_ListInventoryEntries_powershell_topic"></a>

次のコード例は、`Get-SSMInventoryEntriesList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インスタンスのすべてのカスタムインベントリエントリを一覧表示します。**  

```
Get-SSMInventoryEntriesList -InstanceId "i-0cb2b964d3e14fd9f" -TypeName "Custom:RackInfo"
```
**出力:**  

```
CaptureTime   : 2016-08-22T10:01:01Z
Entries       : {Amazon.Runtime.Internal.Util.AlwaysSendDictionary`2[System.String,System.String]}
InstanceId    : i-0cb2b964d3e14fd9f
NextToken     :
SchemaVersion : 1.0
TypeName      : Custom:RackInfo
```
**例 2: この例では詳細を一覧表示します。**  

```
(Get-SSMInventoryEntriesList -InstanceId "i-0cb2b964d3e14fd9f" -TypeName "Custom:RackInfo").Entries
```
**出力:**  

```
Key          Value
---          -----
RackLocation Bay B/Row C/Rack D/Shelf E
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[ListInventoryEntries](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMInventoryEntryList`
<a name="ssm_Get-SSMInventoryEntryList_powershell_topic"></a>

次のコード例は、`Get-SSMInventoryEntryList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インスタンスの `AWS:Network` タイプのインベントリエントリを取得します。**  

```
Get-SSMInventoryEntryList -InstanceId mi-088dcb0ecea37b076 -TypeName AWS:Network | Select-Object -ExpandProperty Entries
```
**出力:**  

```
Key        Value
---        -----
DHCPServer 172.31.11.2
DNSServer  172.31.0.1
Gateway    172.31.11.2
IPV4       172.31.11.222
IPV6       fe12::3456:7da8:901a:12a3
MacAddress 1A:23:4E:5B:FB:67
Name       Amazon Elastic Network Adapter
SubnetMask 255.255.240.0
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[Get-SSMInventoryEntryList](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMInventorySchema`
<a name="ssm_GetInventorySchema_powershell_topic"></a>

次のコード例は、`Get-SSMInventorySchema` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、アカウントのインベントリタイプ名のリストを返します。**  

```
Get-SSMInventorySchema
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[GetInventorySchema](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMLatestEC2Image`
<a name="ssm_Get-SSMLatestEC2Image_powershell_topic"></a>

次のコード例は、`Get-SSMLatestEC2Image` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、最新の Windows AMI をすべて一覧表示します。**  

```
PS Get-SSMLatestEC2Image -Path ami-windows-latest
```
**出力:**  

```
Name                                                                    Value
----                                                                    -----
Windows_Server-2008-R2_SP1-English-64Bit-SQL_2012_SP4_Express           ami-0e5ddd288daff4fab
Windows_Server-2012-R2_RTM-Chinese_Simplified-64Bit-Base                ami-0c5ea64e6bec1cb50
Windows_Server-2012-R2_RTM-Chinese_Traditional-64Bit-Base               ami-09775eff0bf8c113d
Windows_Server-2012-R2_RTM-Dutch-64Bit-Base                             ami-025064b67e28cf5df
...
```
**例 2: この例では、us-west-2 リージョンの特定の Amazon Linux イメージの AMI ID を取得します。**  

```
PS Get-SSMLatestEC2Image -Path ami-amazon-linux-latest -ImageName amzn-ami-hvm-x86_64-ebs -Region us-west-2
```
**出力:**  

```
ami-09b92cd132204c704
```
**例 3: この例では、指定されたワイルドカード表現に一致する最新の Windows AMI をすべて一覧表示します。**  

```
Get-SSMLatestEC2Image -Path ami-windows-latest -ImageName *Windows*2019*English*
```
**出力:**  

```
Name                                                     Value
----                                                     -----
Windows_Server-2019-English-Full-SQL_2017_Web            ami-085e9d27da5b73a42
Windows_Server-2019-English-STIG-Core                    ami-0bfd85c29148c7f80
Windows_Server-2019-English-Full-SQL_2019_Web            ami-02099560d7fb11f20
Windows_Server-2019-English-Full-SQL_2016_SP2_Standard   ami-0d7ae2d81c07bd598
...
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[Get-SSMLatestEC2Image](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMMaintenanceWindow`
<a name="ssm_GetMaintenanceWindow_powershell_topic"></a>

次のコード例は、`Get-SSMMaintenanceWindow` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、メンテナンスウィンドウの詳細を取得します。**  

```
Get-SSMMaintenanceWindow -WindowId "mw-03eb9db42890fb82d"
```
**出力:**  

```
AllowUnassociatedTargets : False
CreatedDate              : 2/20/2017 6:14:05 PM
Cutoff                   : 1
Duration                 : 2
Enabled                  : True
ModifiedDate             : 2/20/2017 6:14:05 PM
Name                     : TestMaintWin
Schedule                 : cron(0 */30 * * * ? *)
WindowId                 : mw-03eb9db42890fb82d
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[GetMaintenanceWindow](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMMaintenanceWindowExecution`
<a name="ssm_GetMaintenanceWindowExecution_powershell_topic"></a>

次のコード例は、`Get-SSMMaintenanceWindowExecution` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、メンテナンスウィンドウの実行の一部として実行されるタスクに関する情報を一覧表示します。**  

```
Get-SSMMaintenanceWindowExecution -WindowExecutionId "518d5565-5969-4cca-8f0e-da3b2a638355"
```
**出力:**  

```
EndTime           : 2/21/2017 4:00:35 PM
StartTime         : 2/21/2017 4:00:34 PM
Status            : FAILED
StatusDetails     : One or more tasks in the orchestration failed.
TaskIds           : {ac0c6ae1-daa3-4a89-832e-d384503b6586}
WindowExecutionId : 518d5565-5969-4cca-8f0e-da3b2a638355
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[GetMaintenanceWindowExecution](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMMaintenanceWindowExecutionList`
<a name="ssm_DescribeMaintenanceWindowExecutions_powershell_topic"></a>

次のコード例は、`Get-SSMMaintenanceWindowExecutionList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、メンテナンスウィンドウにおけるすべての実行を一覧表示します。**  

```
Get-SSMMaintenanceWindowExecutionList -WindowId "mw-03eb9db42890fb82d"
```
**出力:**  

```
EndTime           : 2/20/2017 6:30:17 PM
StartTime         : 2/20/2017 6:30:16 PM
Status            : FAILED
StatusDetails     : One or more tasks in the orchestration failed.
WindowExecutionId : 6f3215cf-4101-4fa0-9b7b-9523269599c7
WindowId          : mw-03eb9db42890fb82d
```
**例 2: この例では、指定されたメンテナンスウィンドウにおける指定された日付より前のすべての実行を一覧表示します。**  

```
$option1 = @{Key="ExecutedBefore";Values=@("2016-11-04T05:00:00Z")}
Get-SSMMaintenanceWindowExecutionList -WindowId "mw-03eb9db42890fb82d" -Filter $option1
```
**例 3: この例では、指定されたメンテナンスウィンドウにおける指定された日付より後のすべての実行を一覧表示します。**  

```
$option1 = @{Key="ExecutedAfter";Values=@("2016-11-04T05:00:00Z")}
Get-SSMMaintenanceWindowExecutionList -WindowId "mw-03eb9db42890fb82d" -Filter $option1
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeMaintenanceWindowExecutions](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMMaintenanceWindowExecutionTask`
<a name="ssm_GetMaintenanceWindowExecutionTask_powershell_topic"></a>

次のコード例は、`Get-SSMMaintenanceWindowExecutionTask` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、メンテナンスウィンドウの実行の一部であったタスクに関する情報を一覧表示します。**  

```
Get-SSMMaintenanceWindowExecutionTask -TaskId "ac0c6ae1-daa3-4a89-832e-d384503b6586" -WindowExecutionId "518d5565-5969-4cca-8f0e-da3b2a638355"
```
**出力:**  

```
EndTime           : 2/21/2017 4:00:35 PM
MaxConcurrency    : 1
MaxErrors         : 1
Priority          : 10
ServiceRole       : arn:aws:iam::123456789012:role/MaintenanceWindowsRole
StartTime         : 2/21/2017 4:00:34 PM
Status            : FAILED
StatusDetails     : The maximum error count was exceeded.
TaskArn           : AWS-RunShellScript
TaskExecutionId   : ac0c6ae1-daa3-4a89-832e-d384503b6586
TaskParameters    : {Amazon.Runtime.Internal.Util.AlwaysSendDictionary`2[System.String,Amazon.SimpleSystemsManagement.Model.MaintenanceWindowTaskPara
                    meterValueExpression]}
Type              : RUN_COMMAND
WindowExecutionId : 518d5565-5969-4cca-8f0e-da3b2a638355
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[GetMaintenanceWindowExecutionTask](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMMaintenanceWindowExecutionTaskInvocationList`
<a name="ssm_DescribeMaintenanceWindowExecutionTaskInvocations_powershell_topic"></a>

次のコード例は、`Get-SSMMaintenanceWindowExecutionTaskInvocationList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、メンテナンスウィンドウの実行の一部として実行される、タスクの呼び出しを一覧表示します。**  

```
Get-SSMMaintenanceWindowExecutionTaskInvocationList -TaskId "ac0c6ae1-daa3-4a89-832e-d384503b6586" -WindowExecutionId "518d5565-5969-4cca-8f0e-da3b2a638355"
```
**出力:**  

```
EndTime           : 2/21/2017 4:00:34 PM
ExecutionId       :
InvocationId      : e274b6e1-fe56-4e32-bd2a-8073c6381d8b
OwnerInformation  :
Parameters        : {"documentName":"AWS-RunShellScript","instanceIds":["i-0000293ffd8c57862"],"parameters":{"commands":["df"]},"maxConcurrency":"1",
                    "maxErrors":"1"}
StartTime         : 2/21/2017 4:00:34 PM
Status            : FAILED
StatusDetails     : The instance IDs list contains an invalid entry.
TaskExecutionId   : ac0c6ae1-daa3-4a89-832e-d384503b6586
WindowExecutionId : 518d5565-5969-4cca-8f0e-da3b2a638355
WindowTargetId    :
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeMaintenanceWindowExecutionTaskInvocations](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMMaintenanceWindowExecutionTaskList`
<a name="ssm_DescribeMaintenanceWindowExecutionTasks_powershell_topic"></a>

次のコード例は、`Get-SSMMaintenanceWindowExecutionTaskList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、メンテナンスウィンドウの実行に関連するタスクを一覧表示します。**  

```
Get-SSMMaintenanceWindowExecutionTaskList -WindowExecutionId "518d5565-5969-4cca-8f0e-da3b2a638355"
```
**出力:**  

```
EndTime           : 2/21/2017 4:00:35 PM
StartTime         : 2/21/2017 4:00:34 PM
Status            : SUCCESS
TaskArn           : AWS-RunShellScript
TaskExecutionId   : ac0c6ae1-daa3-4a89-832e-d384503b6586
TaskType          : RUN_COMMAND
WindowExecutionId : 518d5565-5969-4cca-8f0e-da3b2a638355
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeMaintenanceWindowExecutionTasks](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMMaintenanceWindowList`
<a name="ssm_DescribeMaintenanceWindows_powershell_topic"></a>

次のコード例は、`Get-SSMMaintenanceWindowList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、アカウントにおけるすべてのメンテナンスウィンドウを一覧表示します。**  

```
Get-SSMMaintenanceWindowList
```
**出力:**  

```
Cutoff   : 1
Duration : 4
Enabled  : True
Name     : My-First-Maintenance-Window
WindowId : mw-06d59c1a07c022145
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeMaintenanceWindows](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMMaintenanceWindowTarget`
<a name="ssm_DescribeMaintenanceWindowTargets_powershell_topic"></a>

次のコード例は、`Get-SSMMaintenanceWindowTarget` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、メンテナンスウィンドウのすべてのターゲットを一覧表示します。**  

```
Get-SSMMaintenanceWindowTarget -WindowId "mw-06cf17cbefcb4bf4f"
```
**出力:**  

```
OwnerInformation : Single instance
ResourceType     : INSTANCE
Targets          : {InstanceIds}
WindowId         : mw-06cf17cbefcb4bf4f
WindowTargetId   : 350d44e6-28cc-44e2-951f-4b2c985838f6

OwnerInformation : Two instances in a list
ResourceType     : INSTANCE
Targets          : {InstanceIds}
WindowId         : mw-06cf17cbefcb4bf4f
WindowTargetId   : e078a987-2866-47be-bedd-d9cf49177d3a
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeMaintenanceWindowTargets](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMMaintenanceWindowTaskList`
<a name="ssm_DescribeMaintenanceWindowTasks_powershell_topic"></a>

次のコード例は、`Get-SSMMaintenanceWindowTaskList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、メンテナンスウィンドウのすべてのタスクを一覧表示します。**  

```
Get-SSMMaintenanceWindowTaskList -WindowId "mw-06cf17cbefcb4bf4f"
```
**出力:**  

```
LoggingInfo    :
MaxConcurrency : 1
MaxErrors      : 1
Priority       : 10
ServiceRoleArn : arn:aws:iam::123456789012:role/MaintenanceWindowsRole
Targets        : {InstanceIds}
TaskArn        : AWS-RunShellScript
TaskParameters : {[commands, Amazon.SimpleSystemsManagement.Model.MaintenanceWindowTaskParameterValueExpression]}
Type           : RUN_COMMAND
WindowId       : mw-06cf17cbefcb4bf4f
WindowTaskId   : a23e338d-ff30-4398-8aa3-09cd052ebf17
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeMaintenanceWindowTasks](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMParameterHistory`
<a name="ssm_GetParameterHistory_powershell_topic"></a>

次のコード例は、`Get-SSMParameterHistory` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、パラメータの値の履歴を一覧表示します。**  

```
Get-SSMParameterHistory -Name "Welcome"
```
**出力:**  

```
Description      :
KeyId            :
LastModifiedDate : 3/3/2017 6:55:25 PM
LastModifiedUser : arn:aws:iam::123456789012:user/admin
Name             : Welcome
Type             : String
Value            : helloWorld
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[GetParameterHistory](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMParameterList`
<a name="ssm_DescribeParameters_powershell_topic"></a>

次のコード例は、`Get-SSMParameterList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、すべてのパラメータを一覧表示します。**  

```
Get-SSMParameterList
```
**出力:**  

```
Description      :
KeyId            :
LastModifiedDate : 3/3/2017 6:58:23 PM
LastModifiedUser : arn:aws:iam::123456789012:user/admin
Name             : Welcome
Type             : String
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribeParameters](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMParameterValue`
<a name="ssm_GetParameters_powershell_topic"></a>

次のコード例は、`Get-SSMParameterValue` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、パラメータの値を一覧表示します。**  

```
Get-SSMParameterValue -Name "Welcome"
```
**出力:**  

```
InvalidParameters Parameters
----------------- ----------
{}                {Welcome}
```
**例 2: この例では、値の詳細を一覧表示します。**  

```
(Get-SSMParameterValue -Name "Welcome").Parameters
```
**出力:**  

```
Name    Type   Value
----    ----   -----
Welcome String Good day, Sunshine!
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[GetParameters](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMPatchBaseline`
<a name="ssm_DescribePatchBaselines_powershell_topic"></a>

次のコード例は、`Get-SSMPatchBaseline` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、すべてのパッチベースラインを一覧表示します。**  

```
Get-SSMPatchBaseline
```
**出力:**  

```
BaselineDescription                                             BaselineId                                                            BaselineName
-------------------                                             ----------                                                            ------------
Default Patch Baseline Provided by AWS.                         arn:aws:ssm:us-west-2:123456789012:patchbaseline/pb-04fb4ae6142167966 AWS-DefaultP...
Baseline containing all updates approved for production systems pb-045f10b4f382baeda                                                  Production-B...
Baseline containing all updates approved for production systems pb-0a2f1059b670ebd31                                                  Production-B...
```
**例 2: この例では、 が提供するすべてのパッチベースラインを一覧表示します AWS。この例で使用される構文には、PowerShell バージョン 3 以降が必要です。**  

```
$filter1 = @{Key="OWNER";Values=@("AWS")}
```
**出力:**  

```
Get-SSMPatchBaseline -Filter $filter1
```
**例 3: この例では、所有者しているすべてのパッチベースラインを一覧表示します。この例で使用される構文には、PowerShell バージョン 3 以降が必要です。**  

```
$filter1 = @{Key="OWNER";Values=@("Self")}
```
**出力:**  

```
Get-SSMPatchBaseline -Filter $filter1
```
**例 4: PowerShell バージョン 2 では、New-Object を使用して各タグを作成する必要があります。**  

```
$filter1 = New-Object Amazon.SimpleSystemsManagement.Model.PatchOrchestratorFilter
$filter1.Key = "OWNER"
$filter1.Values = "AWS"

Get-SSMPatchBaseline -Filter $filter1
```
**出力:**  

```
BaselineDescription                     BaselineId                                                            BaselineName             DefaultBaselin
                                                                                                                                       e
-------------------                     ----------                                                            ------------             --------------
Default Patch Baseline Provided by AWS. arn:aws:ssm:us-west-2:123456789012:patchbaseline/pb-04fb4ae6142167966 AWS-DefaultPatchBaseline True
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribePatchBaselines](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMPatchBaselineDetail`
<a name="ssm_GetPatchBaseline_powershell_topic"></a>

次のコード例は、`Get-SSMPatchBaselineDetail` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、パッチベースラインの詳細を表示します。**  

```
Get-SSMPatchBaselineDetail -BaselineId "pb-03da896ca3b68b639"
```
**出力:**  

```
ApprovalRules   : Amazon.SimpleSystemsManagement.Model.PatchRuleGroup
ApprovedPatches : {}
BaselineId      : pb-03da896ca3b68b639
CreatedDate     : 3/3/2017 5:02:19 PM
Description     : Baseline containing all updates approved for production systems
GlobalFilters   : Amazon.SimpleSystemsManagement.Model.PatchFilterGroup
ModifiedDate    : 3/3/2017 5:02:19 PM
Name            : Production-Baseline
PatchGroups     : {}
RejectedPatches : {}
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[GetPatchBaseline](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMPatchBaselineForPatchGroup`
<a name="ssm_GetPatchBaselineForPatchGroup_powershell_topic"></a>

次のコード例は、`Get-SSMPatchBaselineForPatchGroup` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、パッチグループのパッチベースラインを表示します。**  

```
Get-SSMPatchBaselineForPatchGroup -PatchGroup "Production"
```
**出力:**  

```
BaselineId           PatchGroup
----------           ----------
pb-045f10b4f382baeda Production
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[GetPatchBaselineForPatchGroup](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMPatchGroup`
<a name="ssm_DescribePatchGroups_powershell_topic"></a>

次のコード例は、`Get-SSMPatchGroup` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、パッチグループの登録を一覧表示します。**  

```
Get-SSMPatchGroup
```
**出力:**  

```
BaselineIdentity                                           PatchGroup
----------------                                           ----------
Amazon.SimpleSystemsManagement.Model.PatchBaselineIdentity Production
```
+  API の詳細については、「AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribePatchGroups](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMPatchGroupState`
<a name="ssm_DescribePatchGroupState_powershell_topic"></a>

次のコード例は、`Get-SSMPatchGroupState` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、パッチグループのパッチコンプライアンスの概要を取得します。**  

```
Get-SSMPatchGroupState -PatchGroup "Production"
```
**出力:**  

```
Instances                          : 4
InstancesWithFailedPatches         : 1
InstancesWithInstalledOtherPatches : 4
InstancesWithInstalledPatches      : 3
InstancesWithMissingPatches        : 0
InstancesWithNotApplicablePatches  : 0
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DescribePatchGroupState](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMResourceComplianceSummaryList`
<a name="ssm_ListResourceComplianceSummaries_powershell_topic"></a>

次のコード例は、`Get-SSMResourceComplianceSummaryList` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、リソースレベルの概要数を取得します。概要には、「Windows10」に一致する製品の準拠ステータスと非準拠ステータス、および詳細なコンプライアンス項目の重要度数に関する情報が含まれます。MaxResult のデフォルトは、パラメータが指定されていない場合は 100 であり、この値は有効ではないため、MaxResult パラメータが追加され、値は 50 に設定されます。**  

```
$FilterValues = @{
		"Key"="Product"
        "Type"="EQUAL"
        "Values"="Windows10"
}
        Get-SSMResourceComplianceSummaryList -Filter $FilterValues -MaxResult 50
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[ListResourceComplianceSummaries](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Get-SSMResourceTag`
<a name="ssm_ListTagsForResource_powershell_topic"></a>

次のコード例は、`Get-SSMResourceTag` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、メンテナンスウィンドウのタグを一覧表示します。**  

```
Get-SSMResourceTag -ResourceId "mw-03eb9db42890fb82d" -ResourceType "MaintenanceWindow"
```
**出力:**  

```
Key   Value
---   -----
Stack Production
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[ListTagsForResource](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `New-SSMActivation`
<a name="ssm_CreateActivation_powershell_topic"></a>

次のコード例は、`New-SSMActivation` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、マネージドインスタンスを作成します。**  

```
New-SSMActivation -DefaultInstanceName "MyWebServers" -IamRole "SSMAutomationRole" -RegistrationLimit 10
```
**出力:**  

```
ActivationCode       ActivationId
--------------       ------------
KWChhOxBTiwDcKE9BlKC 08e51e79-1e36-446c-8e63-9458569c1363
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[CreateActivation](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `New-SSMAssociation`
<a name="ssm_CreateAssociation_powershell_topic"></a>

次のコード例は、`New-SSMAssociation` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インスタンス ID を使用して、設定ドキュメントをインスタンスに関連付けます。**  

```
New-SSMAssociation -InstanceId "i-0cb2b964d3e14fd9f" -Name "AWS-UpdateSSMAgent"
```
**出力:**  

```
Name                  : AWS-UpdateSSMAgent
InstanceId            : i-0000293ffd8c57862
Date                  : 2/23/2017 6:55:22 PM
Status.Name           : Associated
Status.Date           : 2/20/2015 8:31:11 AM
Status.Message        : Associated with AWS-UpdateSSMAgent
Status.AdditionalInfo :
```
**例 2: この例では、ターゲットを使用して、設定ドキュメントをインスタンスに関連付けます。**  

```
$target = @{Key="instanceids";Values=@("i-0cb2b964d3e14fd9f")}
New-SSMAssociation -Name "AWS-UpdateSSMAgent" -Target $target
```
**出力:**  

```
Name                  : AWS-UpdateSSMAgent
InstanceId            :
Date                  : 3/1/2017 6:22:21 PM
Status.Name           :
Status.Date           :
Status.Message        :
Status.AdditionalInfo :
```
**例 3: この例では、ターゲットとパラメータを使用して、設定ドキュメントをインスタンスに関連付けます。**  

```
$target = @{Key="instanceids";Values=@("i-0cb2b964d3e14fd9f")}
$params = @{
  "action"="configure"
  "mode"="ec2"
  "optionalConfigurationSource"="ssm"
  "optionalConfigurationLocation"=""
  "optionalRestart"="yes"
}
New-SSMAssociation -Name "Configure-CloudWatch" -AssociationName "CWConfiguration" -Target $target -Parameter $params
```
**出力:**  

```
Name                  : Configure-CloudWatch
InstanceId            :
Date                  : 5/17/2018 3:17:44 PM
Status.Name           :
Status.Date           :
Status.Message        :
Status.AdditionalInfo :
```
**例 4: この例では、`AWS-GatherSoftwareInventory` を使用して、リージョン内におけるすべてのインスタンスとの関連付けを作成します。また、収集するパラメータにカスタムファイルとレジストリの場所を指定します。**  

```
$params = [Collections.Generic.Dictionary[String,Collections.Generic.List[String]]]::new()
$params["windowsRegistry"] ='[{"Path":"HKEY_LOCAL_MACHINE\SOFTWARE\Amazon\MachineImage","Recursive":false,"ValueNames":["AMIName"]}]'
$params["files"] = '[{"Path":"C:\Program Files","Pattern":["*.exe"],"Recursive":true}, {"Path":"C:\ProgramData","Pattern":["*.log"],"Recursive":true}]' 
New-SSMAssociation -AssociationName new-in-mum -Name AWS-GatherSoftwareInventory -Target @{Key="instanceids";Values="*"} -Parameter $params -region ap-south-1 -ScheduleExpression "rate(720 minutes)"
```
**出力:**  

```
Name                  : AWS-GatherSoftwareInventory
InstanceId            :
Date                  : 6/9/2019 8:57:56 AM
Status.Name           :
Status.Date           :
Status.Message        :
Status.AdditionalInfo :
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[CreateAssociation](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `New-SSMAssociationFromBatch`
<a name="ssm_CreateAssociationBatch_powershell_topic"></a>

次のコード例は、`New-SSMAssociationFromBatch` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、設定ドキュメントを複数のインスタンスに関連付けます。出力では、成功したオペレーションと失敗したオペレーションのリストが返されます (該当する場合)。**  

```
$option1 = @{InstanceId="i-0cb2b964d3e14fd9f";Name=@("AWS-UpdateSSMAgent")}
$option2 = @{InstanceId="i-0000293ffd8c57862";Name=@("AWS-UpdateSSMAgent")}
New-SSMAssociationFromBatch -Entry $option1,$option2
```
**出力:**  

```
Failed  Successful
------  ----------
{}      {Amazon.SimpleSystemsManagement.Model.FailedCreateAssociation, Amazon.SimpleSystemsManagement.Model.FailedCreateAsso...
```
**例 2: この例では、成功したオペレーションの詳細を表示します。**  

```
$option1 = @{InstanceId="i-0cb2b964d3e14fd9f";Name=@("AWS-UpdateSSMAgent")}
$option2 = @{InstanceId="i-0000293ffd8c57862";Name=@("AWS-UpdateSSMAgent")}
(New-SSMAssociationFromBatch -Entry $option1,$option2).Successful
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[CreateAssociationBatch](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `New-SSMDocument`
<a name="ssm_CreateDocument_powershell_topic"></a>

次のコード例は、`New-SSMDocument` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、アカウントにドキュメントを作成します。ドキュメントは JSON 形式である必要があります。設定ドキュメントの記述については、「SSM API Reference」の「Configuration Document」を参照してください。**  

```
New-SSMDocument -Content (Get-Content -Raw "c:\temp\RunShellScript.json") -Name "RunShellScript" -DocumentType "Command"
```
**出力:**  

```
CreatedDate     : 3/1/2017 1:21:33 AM
DefaultVersion  : 1
Description     : Run an updated script
DocumentType    : Command
DocumentVersion : 1
Hash            : 1d5ce820e999ff051eb4841ed887593daf77120fd76cae0d18a53cc42e4e22c1
HashType        : Sha256
LatestVersion   : 1
Name            : RunShellScript
Owner           : 809632081692
Parameters      : {commands}
PlatformTypes   : {Linux}
SchemaVersion   : 2.0
Sha1            :
Status          : Creating
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[CreateDocument](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `New-SSMMaintenanceWindow`
<a name="ssm_CreateMaintenanceWindow_powershell_topic"></a>

次のコード例は、`New-SSMMaintenanceWindow` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、そのウィンドウは、毎週火曜日の午後 4 時に 4 時間実行され (カットオフは 1 時間)、関連付けられていないターゲットを許可する、指定された名前の新しいメンテナンスウィンドウを作成します。**  

```
New-SSMMaintenanceWindow -Name "MyMaintenanceWindow" -Duration 4 -Cutoff 1 -AllowUnassociatedTarget $true -Schedule "cron(0 16 ? * TUE *)"
```
**出力:**  

```
mw-03eb53e1ea7383998
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[CreateMaintenanceWindow](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `New-SSMPatchBaseline`
<a name="ssm_CreatePatchBaseline_powershell_topic"></a>

次のコード例は、`New-SSMPatchBaseline` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、本番環境で Windows Server 2019 を実行しているマネージドインスタンスに対して、Microsoft からリリースされてから 7 日後にパッチを承認するパッチベースラインを作成します。**  

```
$rule = New-Object Amazon.SimpleSystemsManagement.Model.PatchRule
$rule.ApproveAfterDays = 7

$ruleFilters = New-Object Amazon.SimpleSystemsManagement.Model.PatchFilterGroup

$patchFilter = New-Object Amazon.SimpleSystemsManagement.Model.PatchFilter
$patchFilter.Key="PRODUCT"
$patchFilter.Values="WindowsServer2019"

$severityFilter = New-Object Amazon.SimpleSystemsManagement.Model.PatchFilter
$severityFilter.Key="MSRC_SEVERITY"
$severityFilter.Values.Add("Critical")
$severityFilter.Values.Add("Important")
$severityFilter.Values.Add("Moderate")

$classificationFilter = New-Object Amazon.SimpleSystemsManagement.Model.PatchFilter
$classificationFilter.Key = "CLASSIFICATION"
$classificationFilter.Values.Add( "SecurityUpdates" )
$classificationFilter.Values.Add( "Updates" )
$classificationFilter.Values.Add( "UpdateRollups" )
$classificationFilter.Values.Add( "CriticalUpdates" )

$ruleFilters.PatchFilters.Add($severityFilter)
$ruleFilters.PatchFilters.Add($classificationFilter)
$ruleFilters.PatchFilters.Add($patchFilter)
$rule.PatchFilterGroup = $ruleFilters

New-SSMPatchBaseline -Name "Production-Baseline-Windows2019" -Description "Baseline containing all updates approved for production systems" -ApprovalRules_PatchRule $rule
```
**出力:**  

```
pb-0z4z6221c4296b23z
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[CreatePatchBaseline](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Register-SSMDefaultPatchBaseline`
<a name="ssm_RegisterDefaultPatchBaseline_powershell_topic"></a>

次のコード例は、`Register-SSMDefaultPatchBaseline` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、パッチベースラインをデフォルトのパッチベースラインとして登録します。**  

```
Register-SSMDefaultPatchBaseline -BaselineId "pb-03da896ca3b68b639"
```
**出力:**  

```
pb-03da896ca3b68b639
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[RegisterDefaultPatchBaseline](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Register-SSMPatchBaselineForPatchGroup`
<a name="ssm_RegisterPatchBaselineForPatchGroup_powershell_topic"></a>

次のコード例は、`Register-SSMPatchBaselineForPatchGroup` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、パッチグループのパッチベースラインを登録します。**  

```
Register-SSMPatchBaselineForPatchGroup -BaselineId "pb-03da896ca3b68b639" -PatchGroup "Production"
```
**出力:**  

```
BaselineId           PatchGroup
----------           ----------
pb-03da896ca3b68b639 Production
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[RegisterPatchBaselineForPatchGroup](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Register-SSMTargetWithMaintenanceWindow`
<a name="ssm_RegisterTargetWithMaintenanceWindow_powershell_topic"></a>

次のコード例は、`Register-SSMTargetWithMaintenanceWindow` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インスタンスをメンテナンスウィンドウに登録します。**  

```
$option1 = @{Key="InstanceIds";Values=@("i-0000293ffd8c57862")}
Register-SSMTargetWithMaintenanceWindow -WindowId "mw-06cf17cbefcb4bf4f" -Target $option1 -OwnerInformation "Single instance" -ResourceType "INSTANCE"
```
**出力:**  

```
d8e47760-23ed-46a5-9f28-927337725398
```
**例 2: この例では、複数のインスタンスをメンテナンスウィンドウに登録します。**  

```
$option1 = @{Key="InstanceIds";Values=@("i-0000293ffd8c57862","i-0cb2b964d3e14fd9f")}
Register-SSMTargetWithMaintenanceWindow -WindowId "mw-06cf17cbefcb4bf4f" -Target $option1 -OwnerInformation "Single instance" -ResourceType "INSTANCE"
```
**出力:**  

```
6ab5c208-9fc4-4697-84b7-b02a6cc25f7d
```
**例 3: この例では、EC2 タグを使用して、インスタンスをメンテナンスウィンドウに登録します。**  

```
$option1 = @{Key="tag:Environment";Values=@("Production")}
Register-SSMTargetWithMaintenanceWindow -WindowId "mw-06cf17cbefcb4bf4f" -Target $option1 -OwnerInformation "Production Web Servers" -ResourceType "INSTANCE"
```
**出力:**  

```
2994977e-aefb-4a71-beac-df620352f184
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[RegisterTargetWithMaintenanceWindow](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Register-SSMTaskWithMaintenanceWindow`
<a name="ssm_RegisterTaskWithMaintenanceWindow_powershell_topic"></a>

次のコード例は、`Register-SSMTaskWithMaintenanceWindow` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インスタンス ID を使用して、タスクをメンテナンスウィンドウに登録します。出力はタスク ID です。**  

```
$parameters = @{}
$parameterValues = New-Object Amazon.SimpleSystemsManagement.Model.MaintenanceWindowTaskParameterValueExpression
$parameterValues.Values = @("Install")
$parameters.Add("Operation", $parameterValues)

Register-SSMTaskWithMaintenanceWindow -WindowId "mw-03a342e62c96d31b0" -ServiceRoleArn "arn:aws:iam::123456789012:role/MaintenanceWindowsRole" -MaxConcurrency 1 -MaxError 1 -TaskArn "AWS-RunShellScript" -Target @{ Key="InstanceIds";Values="i-0000293ffd8c57862" } -TaskType "RUN_COMMAND" -Priority 10 -TaskParameter $parameters
```
**出力:**  

```
f34a2c47-ddfd-4c85-a88d-72366b69af1b
```
**例 2: この例では、ターゲット ID を使用して、タスクをメンテナンスウィンドウに登録します。出力はタスク ID です。**  

```
$parameters = @{}
$parameterValues = New-Object Amazon.SimpleSystemsManagement.Model.MaintenanceWindowTaskParameterValueExpression
$parameterValues.Values = @("Install")
$parameters.Add("Operation", $parameterValues)

register-ssmtaskwithmaintenancewindow -WindowId "mw-03a342e62c96d31b0" -ServiceRoleArn "arn:aws:iam::123456789012:role/MaintenanceWindowsRole" -MaxConcurrency 1 -MaxError 1 -TaskArn "AWS-RunShellScript" -Target @{ Key="WindowTargetIds";Values="350d44e6-28cc-44e2-951f-4b2c985838f6" } -TaskType "RUN_COMMAND" -Priority 10 -TaskParameter $parameters
```
**出力:**  

```
f34a2c47-ddfd-4c85-a88d-72366b69af1b
```
**例 3: この例では、run コマンドドキュメント `AWS-RunPowerShellScript` のパラメータオブジェクトを作成し、ターゲット ID を使用して任意のメンテナンスウィンドウを持つタスクを作成します。返される出力はタスク ID です。**  

```
$parameters = [Collections.Generic.Dictionary[String,Collections.Generic.List[String]]]::new()
$parameters.Add("commands",@("ipconfig","dir env:\computername"))
$parameters.Add("executionTimeout",@(3600))

$props = @{
    WindowId = "mw-0123e4cce56ff78ae"
    ServiceRoleArn = "arn:aws:iam::123456789012:role/MaintenanceWindowsRole"
    MaxConcurrency = 1
    MaxError = 1
    TaskType = "RUN_COMMAND"
    TaskArn = "AWS-RunPowerShellScript"
    Target = @{Key="WindowTargetIds";Values="fe1234ea-56d7-890b-12f3-456b789bee0f"}
    Priority = 1
    RunCommand_Parameter = $parameters
    Name = "set-via-cmdlet"
}

Register-SSMTaskWithMaintenanceWindow @props
```
**出力:**  

```
f1e2ef34-5678-12e3-456a-12334c5c6cbe
```
**例 4: この例では、 という名前のドキュメントを使用して AWS Systems Manager Automation タスクを登録します`Create-Snapshots`。**  

```
$automationParameters = @{}
$automationParameters.Add( "instanceId", @("{{ TARGET_ID }}") )
$automationParameters.Add( "AutomationAssumeRole", @("{arn:aws:iam::111111111111:role/AutomationRole}") )
$automationParameters.Add( "SnapshotTimeout", @("PT20M") )
Register-SSMTaskWithMaintenanceWindow -WindowId mw-123EXAMPLE456`
    -ServiceRoleArn "arn:aws:iam::123456789012:role/MW-Role"`
    -MaxConcurrency 1 -MaxError 1 -TaskArn "CreateVolumeSnapshots"`
    -Target @{ Key="WindowTargetIds";Values="4b5acdf4-946c-4355-bd68-4329a43a5fd1" }`
    -TaskType "AUTOMATION"`
    -Priority 4`
    -Automation_DocumentVersion '$DEFAULT' -Automation_Parameter $automationParameters -Name "Create-Snapshots"
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[RegisterTaskWithMaintenanceWindow](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Remove-SSMActivation`
<a name="ssm_DeleteActivation_powershell_topic"></a>

次のコード例は、`Remove-SSMActivation` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、アクティベーションを削除します。コマンドが成功した場合、出力はありません。**  

```
Remove-SSMActivation -ActivationId "08e51e79-1e36-446c-8e63-9458569c1363"
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DeleteActivation](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Remove-SSMAssociation`
<a name="ssm_DeleteAssociation_powershell_topic"></a>

次のコード例は、`Remove-SSMAssociation` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インスタンスとドキュメント間の関連付けを削除します。コマンドが成功した場合、出力はありません。**  

```
Remove-SSMAssociation -InstanceId "i-0cb2b964d3e14fd9f" -Name "AWS-UpdateSSMAgent"
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DeleteAssociation](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Remove-SSMDocument`
<a name="ssm_DeleteDocument_powershell_topic"></a>

次のコード例は、`Remove-SSMDocument` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、ドキュメントを削除します。コマンドが成功した場合、出力はありません。**  

```
Remove-SSMDocument -Name "RunShellScript"
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DeleteDocument](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Remove-SSMMaintenanceWindow`
<a name="ssm_DeleteMaintenanceWindow_powershell_topic"></a>

次のコード例は、`Remove-SSMMaintenanceWindow` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、メンテナンスウィンドウを削除します。**  

```
Remove-SSMMaintenanceWindow -WindowId "mw-06d59c1a07c022145"
```
**出力:**  

```
mw-06d59c1a07c022145
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DeleteMaintenanceWindow](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Remove-SSMParameter`
<a name="ssm_DeleteParameter_powershell_topic"></a>

次のコード例は、`Remove-SSMParameter` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例ではパラメータを削除します。コマンドが成功した場合、出力はありません。**  

```
Remove-SSMParameter -Name "helloWorld"
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DeleteParameter](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Remove-SSMPatchBaseline`
<a name="ssm_DeletePatchBaseline_powershell_topic"></a>

次のコード例は、`Remove-SSMPatchBaseline` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、パッチベースラインを削除します。**  

```
Remove-SSMPatchBaseline -BaselineId "pb-045f10b4f382baeda"
```
**出力:**  

```
pb-045f10b4f382baeda
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DeletePatchBaseline](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Remove-SSMResourceTag`
<a name="ssm_RemoveTagsFromResource_powershell_topic"></a>

次のコード例は、`Remove-SSMResourceTag` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、メンテナンスウィンドウからタグを削除します。コマンドが成功した場合、出力はありません。**  

```
Remove-SSMResourceTag -ResourceId "mw-03eb9db42890fb82d" -ResourceType "MaintenanceWindow" -TagKey "Production"
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[RemoveTagsFromResource](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Send-SSMCommand`
<a name="ssm_SendCommand_powershell_topic"></a>

次のコード例は、`Send-SSMCommand` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、ターゲットインスタンスで echo コマンドを実行します。**  

```
Send-SSMCommand -DocumentName "AWS-RunPowerShellScript" -Parameter @{commands = "echo helloWorld"} -Target @{Key="instanceids";Values=@("i-0cb2b964d3e14fd9f")}
```
**出力:**  

```
CommandId          : d8d190fc-32c1-4d65-a0df-ff5ff3965524
Comment            : 
CompletedCount     : 0
DocumentName       : AWS-RunPowerShellScript
ErrorCount         : 0
ExpiresAfter       : 3/7/2017 10:48:37 PM
InstanceIds        : {}
MaxConcurrency     : 50
MaxErrors          : 0
NotificationConfig : Amazon.SimpleSystemsManagement.Model.NotificationConfig
OutputS3BucketName : 
OutputS3KeyPrefix  : 
OutputS3Region     : 
Parameters         : {[commands, Amazon.Runtime.Internal.Util.AlwaysSendList`1[System.String]]}
RequestedDateTime  : 3/7/2017 9:48:37 PM
ServiceRole        : 
Status             : Pending
StatusDetails      : Pending
TargetCount        : 0
Targets            : {instanceids}
```
**例 2: この例は、ネストされたパラメータを受け入れるコマンドを実行する方法を示しています。**  

```
Send-SSMCommand -DocumentName "AWS-RunRemoteScript" -Parameter @{ sourceType="GitHub";sourceInfo='{"owner": "me","repository": "amazon-ssm","path": "Examples/Install-Win32OpenSSH"}'; "commandLine"=".\Install-Win32OpenSSH.ps1"} -InstanceId i-0cb2b964d3e14fd9f
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[SendCommand](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Start-SSMAutomationExecution`
<a name="ssm_StartAutomationExecution_powershell_topic"></a>

次のコード例は、`Start-SSMAutomationExecution` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、オートメーションロール、AMI ソース ID、および Amazon EC2 インスタンスロールを指定するドキュメントを実行します。**  

```
Start-SSMAutomationExecution -DocumentName AWS-UpdateLinuxAmi -Parameter @{'AutomationAssumeRole'='arn:aws:iam::123456789012:role/SSMAutomationRole';'SourceAmiId'='ami-f173cc91';'InstanceIamRole'='EC2InstanceRole'}
```
**出力:**  

```
3a532a4f-0382-11e7-9df7-6f11185f6dd1
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[StartAutomationExecution](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Start-SSMSession`
<a name="ssm_StartSession_powershell_topic"></a>

次のコード例は、`Start-SSMSession` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、Session Manager のセッションのターゲットへの接続を開始し、ポート転送を有効にします。注: AWSCredentials を使用して設定していない場合は、Region パラメータを追加する必要があります。**  

```
Start-SSMSession -Target 'i-064578e5e7454488f' -DocumentName 'AWS-StartPortForwardingSession' -Parameter @{ localPortNumber = '8080'; portNumber = '80' } -Region 'us-west-1'
```
**出力:**  

```
Starting session with SessionId: testUser-xi4glew849asyeryde34u4dfsdfy
Port 8080 opened for sessionId testUser-xi4glew849asyeryde34u4dfsdfy.
Waiting for connections...
```
**例 2: この例では、Session Manager セッションに指定されたインスタンスを使用してインタラクティブセッションを作成します。**  

```
Start-SSMSession -Target 'i-1234567890abcdef0' -Region 'us-west-1'
```
**出力:**  

```
Starting session with SessionId : testUser-xi4glew849asyeryde34u4dfsdfy
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
                                                                                                                                                                                                
Install the latest PowerShell for new features and improvements!
                                                                                                                                                      
PS C:\Windows\system32> whoami
ec2amaz-fnsdrwv\ec2-test-user
PS C:\Windows\system32>
```
**例 3: この例では、セッションに接続せずにセッションを作成し、セッションへの接続に必要な SessionId、StreamUrl、TokenValue のプロパティを返します。**  

```
Start-SSMSession -Target 'i-1234567890abcdef0' -Region 'us-west-1' -DisablePluginInvocation
```
**出力:**  

```
SessionId        : testUser-xi4glew849asyeryde34u4dfsdfy
StreamUrl        : {StreamUrl value redacted}
TokenValue       : {Token value redacted}
ContentLength    : 1207
HttpStatusCode   : OK
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[StartSession](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Stop-SSMAutomationExecution`
<a name="ssm_StopAutomationExecution_powershell_topic"></a>

次のコード例は、`Stop-SSMAutomationExecution` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、オートメーションの実行を停止します。コマンドが成功した場合、出力はありません。**  

```
Stop-SSMAutomationExecution -AutomationExecutionId "4105a4fc-f944-11e6-9d32-8fb2db27a909"
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[StopAutomationExecution](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Stop-SSMCommand`
<a name="ssm_CancelCommand_powershell_topic"></a>

次のコード例は、`Stop-SSMCommand` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、コマンドのキャンセルを試みます。オペレーションが成功した場合、出力はありません。**  

```
Stop-SSMCommand -CommandId "9ded293e-e792-4440-8e3e-7b8ec5feaa38"
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[CancelCommand](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Unregister-SSMManagedInstance`
<a name="ssm_DeregisterManagedInstance_powershell_topic"></a>

次のコード例は、`Unregister-SSMManagedInstance` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、マネージドインスタンスを登録解除します。コマンドが成功した場合、出力はありません。**  

```
Unregister-SSMManagedInstance -InstanceId "mi-08ab247cdf1046573"
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DeregisterManagedInstance](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Unregister-SSMPatchBaselineForPatchGroup`
<a name="ssm_DeregisterPatchBaselineForPatchGroup_powershell_topic"></a>

次のコード例は、`Unregister-SSMPatchBaselineForPatchGroup` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、パッチグループをパッチベースラインから登録解除します。**  

```
Unregister-SSMPatchBaselineForPatchGroup -BaselineId "pb-045f10b4f382baeda" -PatchGroup "Production"
```
**出力:**  

```
BaselineId           PatchGroup
----------           ----------
pb-045f10b4f382baeda Production
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DeregisterPatchBaselineForPatchGroup](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Unregister-SSMTargetFromMaintenanceWindow`
<a name="ssm_DeregisterTargetFromMaintenanceWindow_powershell_topic"></a>

次のコード例は、`Unregister-SSMTargetFromMaintenanceWindow` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、メンテナンスウィンドウからターゲットを削除します。**  

```
Unregister-SSMTargetFromMaintenanceWindow -WindowTargetId "6ab5c208-9fc4-4697-84b7-b02a6cc25f7d" -WindowId "mw-06cf17cbefcb4bf4f"
```
**出力:**  

```
WindowId             WindowTargetId
--------             --------------
mw-06cf17cbefcb4bf4f 6ab5c208-9fc4-4697-84b7-b02a6cc25f7d
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DeregisterTargetFromMaintenanceWindow](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Unregister-SSMTaskFromMaintenanceWindow`
<a name="ssm_DeregisterTaskFromMaintenanceWindow_powershell_topic"></a>

次のコード例は、`Unregister-SSMTaskFromMaintenanceWindow` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、メンテナンスウィンドウからタスクを削除します。**  

```
Unregister-SSMTaskFromMaintenanceWindow -WindowTaskId "f34a2c47-ddfd-4c85-a88d-72366b69af1b" -WindowId "mw-03a342e62c96d31b0"
```
**出力:**  

```
WindowId             WindowTaskId
--------             ------------
mw-03a342e62c96d31b0 f34a2c47-ddfd-4c85-a88d-72366b69af1b
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[DeregisterTaskFromMaintenanceWindow](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Update-SSMAssociation`
<a name="ssm_UpdateAssociation_powershell_topic"></a>

次のコード例は、`Update-SSMAssociation` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、新しいドキュメントバージョンとの関連付けを更新します。**  

```
Update-SSMAssociation -AssociationId "93285663-92df-44cb-9f26-2292d4ecc439" -DocumentVersion "1"
```
**出力:**  

```
Name                  : AWS-UpdateSSMAgent
InstanceId            :
Date                  : 3/1/2017 6:22:21 PM
Status.Name           :
Status.Date           :
Status.Message        :
Status.AdditionalInfo :
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[UpdateAssociation](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Update-SSMAssociationStatus`
<a name="ssm_UpdateAssociationStatus_powershell_topic"></a>

次のコード例は、`Update-SSMAssociationStatus` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、インスタンスと設定ドキュメント間の関連付けのステータスを更新します。**  

```
Update-SSMAssociationStatus -Name "AWS-UpdateSSMAgent" -InstanceId "i-0000293ffd8c57862" -AssociationStatus_Date "2015-02-20T08:31:11Z" -AssociationStatus_Name "Pending" -AssociationStatus_Message "temporary_status_change" -AssociationStatus_AdditionalInfo "Additional-Config-Needed"
```
**出力:**  

```
Name                  : AWS-UpdateSSMAgent
InstanceId            : i-0000293ffd8c57862
Date                  : 2/23/2017 6:55:22 PM
Status.Name           : Pending
Status.Date           : 2/20/2015 8:31:11 AM
Status.Message        : temporary_status_change
Status.AdditionalInfo : Additional-Config-Needed
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[UpdateAssociationStatus](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Update-SSMDocument`
<a name="ssm_UpdateDocument_powershell_topic"></a>

次のコード例は、`Update-SSMDocument` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: これは、指定した JSON ファイルの更新内容を含むドキュメントの新しいバージョンを作成するためのものです。ドキュメントは JSON 形式である必要があります。ドキュメントバージョンは、「Get-SSMDocumentVersionList」コマンドレットで取得できます。**  

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

```
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
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[UpdateDocument](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Update-SSMDocumentDefaultVersion`
<a name="ssm_UpdateDocumentDefaultVersion_powershell_topic"></a>

次のコード例は、`Update-SSMDocumentDefaultVersion` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: ここではドキュメントのデフォルトバージョンを更新します。利用可能なドキュメントバージョンは、「Get-SSMDocumentVersionList」コマンドレットで取得できます。**  

```
Update-SSMDocumentDefaultVersion -Name "RunShellScript" -DocumentVersion "2"
```
**出力:**  

```
DefaultVersion Name
-------------- ----
2              RunShellScript
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[UpdateDocumentDefaultVersion](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Update-SSMMaintenanceWindow`
<a name="ssm_UpdateMaintenanceWindow_powershell_topic"></a>

次のコード例は、`Update-SSMMaintenanceWindow` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、メンテナンスウィンドウの名前を更新します。**  

```
Update-SSMMaintenanceWindow -WindowId "mw-03eb9db42890fb82d" -Name "My-Renamed-MW"
```
**出力:**  

```
AllowUnassociatedTargets : False
Cutoff                   : 1
Duration                 : 2
Enabled                  : True
Name                     : My-Renamed-MW
Schedule                 : cron(0 */30 * * * ? *)
WindowId                 : mw-03eb9db42890fb82d
```
**例 2: この例では、メンテナンスウィンドウを有効にします。**  

```
Update-SSMMaintenanceWindow -WindowId "mw-03eb9db42890fb82d" -Enabled $true
```
**出力:**  

```
AllowUnassociatedTargets : False
Cutoff                   : 1
Duration                 : 2
Enabled                  : True
Name                     : My-Renamed-MW
Schedule                 : cron(0 */30 * * * ? *)
WindowId                 : mw-03eb9db42890fb82d
```
**例 3: この例では、メンテナンスウィンドウを無効にします。**  

```
Update-SSMMaintenanceWindow -WindowId "mw-03eb9db42890fb82d" -Enabled $false
```
**出力:**  

```
AllowUnassociatedTargets : False
Cutoff                   : 1
Duration                 : 2
Enabled                  : False
Name                     : My-Renamed-MW
Schedule                 : cron(0 */30 * * * ? *)
WindowId                 : mw-03eb9db42890fb82d
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[UpdateMaintenanceWindow](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Update-SSMManagedInstanceRole`
<a name="ssm_UpdateManagedInstanceRole_powershell_topic"></a>

次のコード例は、`Update-SSMManagedInstanceRole` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、マネージドインスタンスのロールを更新します。コマンドが成功した場合、出力はありません。**  

```
Update-SSMManagedInstanceRole -InstanceId "mi-08ab247cdf1046573" -IamRole "AutomationRole"
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[UpdateManagedInstanceRole](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Update-SSMPatchBaseline`
<a name="ssm_UpdatePatchBaseline_powershell_topic"></a>

次のコード例は、`Update-SSMPatchBaseline` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、2 つのパッチを拒否済み、1 つのパッチを承認済みとして既存のパッチベースラインに追加します。**  

```
Update-SSMPatchBaseline -BaselineId "pb-03da896ca3b68b639" -RejectedPatch "KB2032276","MS10-048" -ApprovedPatch "KB2124261"
```
**出力:**  

```
ApprovalRules   : Amazon.SimpleSystemsManagement.Model.PatchRuleGroup
ApprovedPatches : {KB2124261}
BaselineId      : pb-03da896ca3b68b639
CreatedDate     : 3/3/2017 5:02:19 PM
Description     : Baseline containing all updates approved for production systems
GlobalFilters   : Amazon.SimpleSystemsManagement.Model.PatchFilterGroup
ModifiedDate    : 3/3/2017 5:22:10 PM
Name            : Production-Baseline
RejectedPatches : {KB2032276, MS10-048}
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[UpdatePatchBaseline](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Write-SSMComplianceItem`
<a name="ssm_PutComplianceItems_powershell_topic"></a>

次のコード例は、`Write-SSMComplianceItem` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、任意のマネージドインスタンスのカスタムコンプライアンス項目を書き込みます。**  

```
$item = [Amazon.SimpleSystemsManagement.Model.ComplianceItemEntry]::new()
$item.Id = "07Jun2019-3"
$item.Severity="LOW"
$item.Status="COMPLIANT"
$item.Title="Fin-test-1 - custom"
Write-SSMComplianceItem -ResourceId mi-012dcb3ecea45b678 -ComplianceType Custom:VSSCompliant2 -ResourceType ManagedInstance -Item $item -ExecutionSummary_ExecutionTime "07-Jun-2019"
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[PutComplianceItems](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

### `Write-SSMInventory`
<a name="ssm_PutInventory_powershell_topic"></a>

次のコード例は、`Write-SSMInventory` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例では、ラックの場所情報をインスタンスに割り当てます。コマンドが成功した場合、出力はありません。**  

```
$data = New-Object "System.Collections.Generic.Dictionary[System.String,System.String]"
$data.Add("RackLocation", "Bay B/Row C/Rack D/Shelf F")

$items = New-Object "System.Collections.Generic.List[System.Collections.Generic.Dictionary[System.String, System.String]]"
$items.Add($data)

$customInventoryItem = New-Object Amazon.SimpleSystemsManagement.Model.InventoryItem
$customInventoryItem.CaptureTime = "2016-08-22T10:01:01Z"
$customInventoryItem.Content = $items
$customInventoryItem.TypeName = "Custom:TestRackInfo2"
$customInventoryItem.SchemaVersion = "1.0"

$inventoryItems = @($customInventoryItem)

Write-SSMInventory -InstanceId "i-0cb2b964d3e14fd9f" -Item $inventoryItems
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[PutInventory](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

### `Write-SSMParameter`
<a name="ssm_PutParameter_powershell_topic"></a>

次のコード例は、`Write-SSMParameter` を使用する方法を示しています。

**Tools for PowerShell V5**  
**例 1: この例ではパラメータを作成します。コマンドが成功した場合、出力はありません。**  

```
Write-SSMParameter -Name "Welcome" -Type "String" -Value "helloWorld"
```
**例 2: この例ではパラメータを変更します。コマンドが成功した場合、出力はありません。**  

```
Write-SSMParameter -Name "Welcome" -Type "String" -Value "Good day, Sunshine!" -Overwrite $true
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[PutParameter](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**