搭ListInventoryEntries配 AWS SDK或使用 CLI - AWS SDK 程式碼範例

AWS 文檔 AWS SDK示例 GitHub 回購中有更多SDK示例

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

ListInventoryEntries配 AWS SDK或使用 CLI

下列程式碼範例會示範如何使用ListInventoryEntries

CLI
AWS CLI

範例 1:若要檢視執行環境的特定存貨型態項目

下列list-inventory-entries範例列出特定執行環境上:應用程式 AWS庫存類型的詳細目錄項目。

aws ssm list-inventory-entries \ --instance-id "i-1234567890abcdef0" \ --type-name "AWS:Application"

輸出:

{ "TypeName": "AWS:Application", "InstanceId": "i-1234567890abcdef0", "SchemaVersion": "1.1", "CaptureTime": "2019-02-15T12:17:55Z", "Entries": [ { "Architecture": "i386", "Name": "Amazon SSM Agent", "PackageId": "{88a60be2-89a1-4df8-812a-80863c2a2b68}", "Publisher": "Amazon Web Services", "Version": "2.3.274.0" }, { "Architecture": "x86_64", "InstalledTime": "2018-05-03T13:42:34Z", "Name": "AmazonCloudWatchAgent", "Publisher": "", "Version": "1.200442.0" } ] }

範例 2:若要檢視指派給執行環境的自訂庫存項目

下列list-inventory-entries範例會列出指派給執行個體的自訂詳細目錄項目。

aws ssm list-inventory-entries \ --instance-id "i-1234567890abcdef0" \ --type-name "Custom:RackInfo"

輸出:

{ "TypeName": "Custom:RackInfo", "InstanceId": "i-1234567890abcdef0", "SchemaVersion": "1.0", "CaptureTime": "2021-05-22T10:01:01Z", "Entries": [ { "RackLocation": "Bay B/Row C/Rack D/Shelf E" } ] }
PowerShell
適用的工具 PowerShell

範例 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 指令程ListInventoryEntries式參考中的。