Condividi tramite


WSUS e il catalogo di Microsoft Update

Si applica a: Windows Server 2025, Windows Server 2022, Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012

Microsoft Update Catalog è un servizio che fornisce un elenco di aggiornamenti che possono essere distribuiti in una rete aziendale. È possibile usare il catalogo per trovare informazioni sugli aggiornamenti software Microsoft, i driver e gli hotfix. WSUS currently includes an option to Import Updates from the Microsoft Update Catalog. However, the Import Updates action in WSUS was built using ActiveX, which is now deprecated. Questa funzionalità di importazione all'interno di WSUS è stata sostituita con uno script di PowerShell. Lo script consente di importare un singolo aggiornamento o più aggiornamenti in WSUS. Questo articolo fornisce informazioni sul catalogo, sullo script di importazione e su come usare lo script.

Prerequisiti per l'importazione di aggiornamenti in WSUS

Per importare gli aggiornamenti in WSUS con lo script di PowerShell, sono necessari i prerequisiti seguenti:

  • Qualsiasi computer in cui è installata la console di amministrazione wsus, indipendentemente dal fatto che si tratti o meno di un server WSUS, può essere usato per importare gli aggiornamenti.
    • Quando si importa da un server WSUS, usare un account membro del gruppo Administrators WSUS o del gruppo Administrators locale.
    • Quando si esegue l'importazione da un computer remoto, usare un account membro del gruppo Administrators WSUS e avere autorizzazioni amministrative nel computer locale. I computer remoti devono essere in grado di raggiungere il server WSUS in rete.

Catalogo di Microsoft Update

Microsoft Update Catalog consente di cercare vari campi e categorie di aggiornamento. Questi campi di aggiornamento includono:

  • Update title
  • Description
  • Applicable products
  • Classifications
  • Numeri degli articoli della Knowledge Base nel formato di KB1234567

Quando si cercano gli aggiornamenti hardware o i driver, è anche possibile cercare i campi seguenti:

  • Driver model
  • Manufacturer
  • Class
  • ID hardware in quattro parti, ad esempio PCI\VEN_14E4&DEV_1677&SUBSYS_01AD1028.

È possibile restringere l'ambito della ricerca aggiungendo termini di ricerca aggiuntivi. Per cercare una stringa specifica, usare virgolette doppie.

Note

Il catalogo consente anche di scaricare gli aggiornamenti direttamente dal sito usando il pulsante di download. Tuttavia, gli aggiornamenti scaricati in questo modo sono in .MSU formato. WSUS non può importare gli aggiornamenti nel .MSU formato. Questo tipo di file viene comunemente usato dal programma di installazione autonomo di Windows Update, DISM, o da altri strumenti di aggiornamento. Alcuni strumenti richiedono di estrarre i file da .MSU prima di poterli usare.

Importare gli aggiornamenti in WSUS con PowerShell

Usare le istruzioni seguenti per importare gli aggiornamenti in WSUS:

  1. Copiare lo script di PowerShell per importare gli aggiornamenti in WSUS da questo articolo in un editor di testo e salvarlo come ImportUpdateToWSUS.ps1. Usare una posizione a cui è possibile accedere facilmente, ad esempio C:\temp.

  2. Apri il Microsoft Update Catalog, https://catalog.update.microsoft.com, in un browser.

  3. Cercare un aggiornamento da importare in WSUS.

  4. Nell'elenco restituito selezionare l'aggiornamento da importare in WSUS. Verrà visualizzata la pagina dei dettagli dell'aggiornamento.

  5. Use the Copy button on the update details page to copy the UpdateID.

  6. Lo script può essere usato per importare un singolo aggiornamento o più aggiornamenti.

    • Per importare più aggiornamenti in WSUS, incollare gli UPDATEID per ogni aggiornamento da importare in un file di testo. Elencare un ID di aggiornamento per riga e quindi salvare il file di testo al termine. Usare una posizione a cui è possibile accedere facilmente, ad esempio C:\temp\UpdateIDs.txt.
    • Per importare un singolo aggiornamento, è sufficiente copiare il singolo updateID.
  7. To import updates, open a PowerShell console as an administrator and run the script with the following syntax using any needed parameters:

    C:\temp\ImportUpdateToWSUS.ps1 [-WsusServer] <String> [-PortNumber] <Int32> [-UseSsl] [-UpdateId] <String> [-UpdateIdFilePath] <string> [<CommonParameters>]
    

    Example 1: While signed into a WSUS server that uses the default port, import a single update using the following syntax:

    .\ImportUpdateToWSUS.ps1 -UpdateId 12345678-90ab-cdef-1234-567890abcdef
    

    Example 2: Using a remote computer, import multiple updates into a WSUS server using SSL with the following syntax:

    .\ImportUpdateToWSUS.ps1 -WsusServer WSUSServer.contoso.com -PortNumber 8531 -UseSsl -UpdateIdFilePath C:\temp\UpdateIDs.txt
    
  8. The update files for updates that are imported are downloaded based on your Update files settings. Ad esempio, se si usa l'opzione Scarica i file di aggiornamento in questo server solo quando gli aggiornamenti vengono approvati, i file di aggiornamento vengono scaricati quando l'aggiornamento viene approvato. Per altre informazioni sulle opzioni per l'archiviazione degli aggiornamenti, vedere la sezione 1.3 Scegliere una strategia di archiviazione WSUS.

Script di PowerShell per importare gli aggiornamenti in WSUS

<#
.SYNOPSIS
Powershell script to import an update, or multiple updates into WSUS based on the UpdateID from the catalog.

.DESCRIPTION
This script takes user input and attempts to connect to the WSUS server.
Then it tries to import the update using the provided UpdateID from the catalog.

.INPUTS
The script takes WSUS server Name/IP, WSUS server port, SSL configuration option and UpdateID as input. UpdateID can be viewed and copied from the update details page for any update in the catalog, https://catalog.update.microsoft.com. 

.OUTPUTS
Writes logging information to standard output.

.EXAMPLE
# Use with remote server IP, port and SSL
.\ImportUpdateToWSUS.ps1 -WsusServer 127.0.0.1 -PortNumber 8531 -UseSsl -UpdateId 12345678-90ab-cdef-1234-567890abcdef

.EXAMPLE
# Use with remote server Name, port and SSL
.\ImportUpdateToWSUS.ps1 -WsusServer WSUSServer1.us.contoso.com -PortNumber 8531 -UseSsl -UpdateId 12345678-90ab-cdef-1234-567890abcdef

.EXAMPLE
# Use with remote server IP, defaultport and no SSL
.\ImportUpdateToWSUS.ps1 -WsusServer 127.0.0.1  -UpdateId 12345678-90ab-cdef-1234-567890abcdef

.EXAMPLE
# Use with localhost default port
.\ImportUpdateToWSUS.ps1 -UpdateId 12345678-90ab-cdef-1234-567890abcdef

.EXAMPLE
# Use with localhost default port, file with updateID's
.\ImportUpdateToWSUS.ps1 -UpdateIdFilePath .\file.txt


.NOTES  
# On error, try enabling TLS: https://learn.microsoft.com/mem/configmgr/core/plan-design/security/enable-tls-1-2-client

# Sample registry add for the WSUS server from command line. Restarts the WSUSService and IIS after adding:
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 /V SchUseStrongCrypto /T REG_DWORD /D 1

## Sample registry add for the WSUS server from PowerShell. Restarts WSUSService and IIS after adding:
$registryPath = "HKLM:\Software\Microsoft\.NETFramework\v4.0.30319"
$Name = "SchUseStrongCrypto"
$value = "1" 
if (!(Test-Path $registryPath)) {
    New-Item -Path $registryPath -Force | Out-Null
}
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
Restart-Service WsusService, w3svc

# Update import logs/errors are under %ProgramFiles%\Update Services\LogFiles\SoftwareDistribution.log

#>

param(
    [Parameter(Mandatory = $false, HelpMessage = "Specifies the name of a WSUS server, if not specified connects to localhost")]
    # Specifies the name of a WSUS server, if not specified connects to localhost.
    [string]$WsusServer,

    [Parameter(Mandatory = $false, HelpMessage = "Specifies the port number to use to communicate with the upstream WSUS server, default is 8530")]
    # Specifies the port number to use to communicate with the upstream WSUS server, default is 8530.
    [ValidateSet("80", "443", "8530", "8531")]
    [int32]$PortNumber = 8530,

    [Parameter(Mandatory = $false, HelpMessage = "Specifies that the WSUS server should use Secure Sockets Layer (SSL) via HTTPS to communicate with an upstream server")]
    # Specifies that the WSUS server should use Secure Sockets Layer (SSL) via HTTPS to communicate with an upstream server.  
    [Switch]$UseSsl,

    [Parameter(Mandatory = $true, HelpMessage = "Specifies the update Id we should import to WSUS", ParameterSetName = "Single")]
    # Specifies the update Id we should import to WSUS
    [ValidateNotNullOrEmpty()]
    [String]$UpdateId,

    [Parameter(Mandatory = $true, HelpMessage = "Specifies path to a text file containing a list of update ID's on each line", ParameterSetName = "Multiple")]
    # Specifies path to a text file containing a list of update ID's on each line.
    [ValidateNotNullOrEmpty()]
    [String]$UpdateIdFilePath
)

Set-StrictMode -Version Latest

# set server options
$serverOptions = "Get-WsusServer"
if ($psBoundParameters.containsKey('WsusServer')) { $serverOptions += " -Name $WsusServer -PortNumber $PortNumber" }
if ($UseSsl) { $serverOptions += " -UseSsl" }

# empty updateID list
$updateList = @()

# get update id's
if ($UpdateIdFilePath) {
    if (Test-Path $UpdateIdFilePath) {
        foreach ($id in (Get-Content $UpdateIdFilePath)) {
            $updateList += $id.Trim()
        }
    }
    else {
        Write-Error "[$UpdateIdFilePath]: File not found"
		return
    }
}
else {
    $updateList = @($UpdateId)
}

# get WSUS server
Try {
    Write-Host "Attempting WSUS Connection using $serverOptions... " -NoNewline
    $server = invoke-expression $serverOptions
    Write-Host "Connection Successful"
}
Catch {
    Write-Error $_
    return
}

# empty file list
$FileList = @()

# call ImportUpdateFromCatalogSite on WSUS
foreach ($uid in $updateList) {
    Try {
        Write-Host "Attempting WSUS update import for Update ID: $uid... " -NoNewline
        $server.ImportUpdateFromCatalogSite($uid, $FileList)
        Write-Host "Import Successful"
    }
    Catch {
        Write-Error "Failed. $_"
    }
}

Script parameters

WsusServer: <string>
Specifies the name of a WSUS server. Se non specificato, lo script si connette a localhost.

  • Required: false
  • Default value: localhost

PortNumber: <Int32>
Specifies the port number to use to communicate with the upstream WSUS server.

  • Required: false
  • Default value: 8530
  • Allowed values: 80, 443, 8530, 8531

UseSsl: <switch>
Specifies if Secure Sockets Layer (SSL) via HTTPS should be used to communicate with the WSUS server. Se questo nome di parametro è presente, verifica $true il parametro e la connessione viene stabilita al server WSUS usando SSL; in caso contrario, false. When using the USeSSL parameter, set the PortNumber to either 443 or 8531.

  • Required: false

UpdateId: <string>
Specifies the update ID you want to import to WSUS. Questo parametro è obbligatorio se si importa un singolo aggiornamento. UpdateId can't be used with UpdateIdFilePath.

  • Required: true, when importing a single updateID specified as a script parameter

UpdateIdFilePath: <string>
Specifies the path to a text file containing a list of update IDs on each line. Questo parametro è obbligatorio se si importano più aggiornamenti. UpdateIdFilePath can't be used with UpdateId.

  • Required: true, when using a text file to import multiple updates

CommonParameters:
Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. For more information, see About CommonParameters

Limitazione dell'accesso agli hotfix

Gli amministratori di WSUS potrebbero valutare la possibilità di limitare l'accesso agli hotfix scaricati dal Catalogo di Microsoft Update. Per limitare gli hotfix disponibili, seguire questa procedura:

  1. Avvia la Gestione di Internet Information Services (IIS) console.
  2. Navigate to the Content node under WSUS Administration web site.
  3. On the Content Home pane, double-click in the Authentication option.
  4. Select Anonymous Authentication and select Disable in the Actions pane on the right.
  5. Select Windows Authentication and select Enable in the Actions pane on the right.
  6. Nella console di amministrazione di WSUS creare un gruppo di destinazione WSUS per i computer che necessitano dell'hotfix e aggiungerli al gruppo. Per altre informazioni su computer e gruppi, vedere Gestione di computer client WSUS e gruppi di computer WSUS in questa guida e Configurare i gruppi di computer WSUS nella guida alla distribuzione di WSUS.
  7. Scarica i file per l'hotfix.
  8. Impostare le autorizzazioni di questi file in modo che solo gli account delle macchine possano leggerli. Sarà anche necessario consentire all'account del servizio di rete l'accesso completo ai file.
  9. Approvare l'hotfix per il gruppo di destinazione WSUS creato nel passaggio 2.

Note

You can remove updates that are imported from the Microsoft Update Catalog that are set as either Not Approved or Declined, by running the WSUS Server cleanup Wizard. È possibile importare nuovamente gli aggiornamenti che sono stati rimossi in precedenza dai sistemi WSUS.

Importazione di aggiornamenti in lingue diverse

Il catalogo include aggiornamenti che supportano più lingue.

Important

Trova la corrispondenza con le lingue supportate dal server WSUS con le lingue supportate dagli aggiornamenti importati.

Se il server WSUS non supporta tutte le lingue incluse nell'aggiornamento, l'aggiornamento non verrà distribuito nei computer client. Se un aggiornamento che supporta più lingue è stato scaricato nel server WSUS ma non è ancora stato distribuito nei computer client e un amministratore deseleziona una delle lingue incluse nell'aggiornamento, l'aggiornamento non verrà distribuito ai client.

Troubleshooting

L'oggetto ". La sezione NOTES" dello script può essere usata per la risoluzione dei problemi che possono verificarsi durante l'esecuzione dello script.

  • Se viene visualizzato un errore, provare ad abilitare Transport Layer Security (TLS) 1.2. Per altre informazioni, vedere Come abilitare TLS 1.2 nei client

  • È possibile usare il comando seguente per automatizzare il processo di aggiunta di un valore del Registro di sistema correlato all'uso di crittografia avanzata. Riavviare manualmente il servizio Windows Server Update Services e il servizio World Wide Web Publishing dopo aver aggiunto il valore del Registro di sistema.

    reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 /V SchUseStrongCrypto /T REG_DWORD /D 1
    
  • Eseguire questo script di PowerShell per automatizzare il processo di aggiunta di un valore del Registro di sistema correlato all'uso di crittografia avanzata e riavviare il servizio Windows Server Update Services e il servizio Pubblicazione Web globale:

    $registryPath = "HKLM:\Software\Microsoft\.NETFramework\v4.0.30319"
    $Name = "SchUseStrongCrypto"
    $value = "1"
    if (!(Test-Path $registryPath)) {
       New-Item -Path $registryPath -Force | Out-Null
    }
    New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
    Restart-Service WsusService, w3svc
    
  • Activity and/or errors related to importing updates can be found in %ProgramFiles%\Update Services\LogFiles\SoftwareDistribution.log of the WSUS server where updates are being imported.