Utilizzare DescribeAvailablePatches con un o AWS SDK CLI - Esempi di codice dell'AWS SDK

Ci sono altri AWS SDK esempi disponibili nel repository AWS Doc SDK Examples GitHub .

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

Utilizzare DescribeAvailablePatches con un o AWS SDK CLI

I seguenti esempi di codice mostrano come utilizzareDescribeAvailablePatches.

CLI
AWS CLI

Per ottenere le patch disponibili

L'describe-available-patchesesempio seguente recupera i dettagli su tutte le patch disponibili per Windows Server 2019 che hanno una MSRC gravità di Critical.

aws ssm describe-available-patches \ --filters "Key=PRODUCT,Values=WindowsServer2019" "Key=MSRC_SEVERITY,Values=Critical"

Output:

{ "Patches": [ { "Id": "fe6bd8c2-3752-4c8b-ab3e-1a7ed08767ba", "ReleaseDate": 1544047205.0, "Title": "2018-11 Update for Windows Server 2019 for x64-based Systems (KB4470788)", "Description": "Install this update to resolve issues in Windows. For a complete listing of the issues that are included in this update, see the associated Microsoft Knowledge Base article for more information. After you install this item, you may have to restart your computer.", "ContentUrl": "https://support.microsoft.com/en-us/kb/4470788", "Vendor": "Microsoft", "ProductFamily": "Windows", "Product": "WindowsServer2019", "Classification": "SecurityUpdates", "MsrcSeverity": "Critical", "KbNumber": "KB4470788", "MsrcNumber": "", "Language": "All" }, { "Id": "c96115e1-5587-4115-b851-22baa46a3f11", "ReleaseDate": 1549994410.0, "Title": "2019-02 Security Update for Adobe Flash Player for Windows Server 2019 for x64-based Systems (KB4487038)", "Description": "A security issue has been identified in a Microsoft software product that could affect your system. You can help protect your system by installing this update from Microsoft. For a complete listing of the issues that are included in this update, see the associated Microsoft Knowledge Base article. After you install this update, you may have to restart your system.", "ContentUrl": "https://support.microsoft.com/en-us/kb/4487038", "Vendor": "Microsoft", "ProductFamily": "Windows", "Product": "WindowsServer2019", "Classification": "SecurityUpdates", "MsrcSeverity": "Critical", "KbNumber": "KB4487038", "MsrcNumber": "", "Language": "All" }, ... ] }

Per ottenere i dettagli di una patch specifica

L'describe-available-patchesesempio seguente recupera i dettagli sulla patch specificata.

aws ssm describe-available-patches \ --filters "Key=PATCH_ID,Values=KB4480979"

Output:

{ "Patches": [ { "Id": "680861e3-fb75-432e-818e-d72e5f2be719", "ReleaseDate": 1546970408.0, "Title": "2019-01 Security Update for Adobe Flash Player for Windows Server 2016 for x64-based Systems (KB4480979)", "Description": "A security issue has been identified in a Microsoft software product that could affect your system. You can help protect your system by installing this update from Microsoft. For a complete listing of the issues that are included in this update, see the associated Microsoft Knowledge Base article. After you install this update, you may have to restart your system.", "ContentUrl": "https://support.microsoft.com/en-us/kb/4480979", "Vendor": "Microsoft", "ProductFamily": "Windows", "Product": "WindowsServer2016", "Classification": "SecurityUpdates", "MsrcSeverity": "Critical", "KbNumber": "KB4480979", "MsrcNumber": "", "Language": "All" } ] }

Per ulteriori informazioni, vedere Come funzionano le operazioni di Patch Manager nella Guida per l'utente di AWS Systems Manager.

PowerShell
Strumenti per PowerShell

Esempio 1: in questo esempio vengono ottenute tutte le patch disponibili per Windows Server 2012 con MSRC gravità critica. La sintassi utilizzata da questo esempio richiede la PowerShell versione 3 o successiva.

$filter1 = @{Key="PRODUCT";Values=@("WindowsServer2012")} $filter2 = @{Key="MSRC_SEVERITY";Values=@("Critical")} Get-SSMAvailablePatch -Filter $filter1,$filter2

Output:

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

Esempio 2: con PowerShell la versione 2, è necessario utilizzare New-Object per creare ogni filtro.

$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

Esempio 3: questo esempio recupera tutti gli aggiornamenti rilasciati negli ultimi 20 giorni e applicabili ai prodotti corrispondenti al 2019 WindowsServer

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

Output:

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)