実現したいこと
分類でドライバーにチェックを入れずにUPDATEを行い、しばらくして端末に不具合が出始めたため、
ドライバーのみ手動でインストールしている状態です。
これを必要なドライバーだけWSUSにインポートして各端末へ自動インストールできる状態にするためにshellscriptを使用したいと思います。
Microsoftのサイト内で以下のscriptを見つけましたが、どこにUPDATEIDを記入すればいいか分からないためご教授願います。
発生している問題・分からないこと
必要なドライバーだけWSUSにインポートするためにshellscriptを使用して行おうとしています。
Microsoftのサイト内で以下のscriptを見つけましたが、どこにUPDATEカタログのUPDATEIDを記入すればいいか教えてください。
該当のソースコード
shellscript
1<# 2.SYNOPSIS 3Powershell script to import an update, or multiple updates into WSUS based on the UpdateID from the catalog. 4 5.DESCRIPTION 6This script takes user input and attempts to connect to the WSUS server. 7Then it tries to import the update using the provided UpdateID from the catalog. 8 9.INPUTS 10The 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. 11 12.OUTPUTS 13Writes logging information to standard output. 14 15.EXAMPLE 16# Use with remote server IP, port and SSL 17.\ImportUpdateToWSUS.ps1 -WsusServer 127.0.0.1 -PortNumber 8531 -UseSsl -UpdateId 12345678-90ab-cdef-1234-567890abcdef 18 19.EXAMPLE 20# Use with remote server Name, port and SSL 21.\ImportUpdateToWSUS.ps1 -WsusServer WSUSServer1.us.contoso.com -PortNumber 8531 -UseSsl -UpdateId 12345678-90ab-cdef-1234-567890abcdef 22 23.EXAMPLE 24# Use with remote server IP, defaultport and no SSL 25.\ImportUpdateToWSUS.ps1 -WsusServer 127.0.0.1 -UpdateId 12345678-90ab-cdef-1234-567890abcdef 26 27.EXAMPLE 28# Use with localhost default port 29.\ImportUpdateToWSUS.ps1 -UpdateId 12345678-90ab-cdef-1234-567890abcdef 30 31.EXAMPLE 32# Use with localhost default port, file with updateID's 33.\ImportUpdateToWSUS.ps1 -UpdateIdFilePath .\file.txt 34 35.NOTES 36# On error, try enabling TLS: https://learn.microsoft.com/mem/configmgr/core/plan-design/security/enable-tls-1-2-client 37 38# Sample registry add for the WSUS server from command line. Restarts the WSUSService and IIS after adding: 39reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 /V SchUseStrongCrypto /T REG_DWORD /D 1 40 41## Sample registry add for the WSUS server from PowerShell. Restarts WSUSService and IIS after adding: 42$registryPath = "HKLM:\Software\Microsoft\.NETFramework\v4.0.30319" 43$Name = "SchUseStrongCrypto" 44$value = "1" 45if (!(Test-Path $registryPath)) { 46 New-Item -Path $registryPath -Force | Out-Null 47} 48New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null 49Restart-Service WsusService, w3svc 50 51# Update import logs/errors are under %ProgramFiles%\Update Services\LogFiles\SoftwareDistribution.log 52 53#> 54 55param( 56 [Parameter(Mandatory = $false, HelpMessage = "Specifies the name of a WSUS server, if not specified connects to localhost")] 57 # Specifies the name of a WSUS server, if not specified connects to localhost. 58 [string]$WsusServer, 59 60[Parameter(Mandatory = $false, HelpMessage = "Specifies the port number to use to communicate with the upstream WSUS server, default is 8530")] 61 # Specifies the port number to use to communicate with the upstream WSUS server, default is 8530. 62 [ValidateSet("80", "443", "8530", "8531")] 63 [int32]$PortNumber = 8530, 64 65[Parameter(Mandatory = $false, HelpMessage = "Specifies that the WSUS server should use Secure Sockets Layer (SSL) via HTTPS to communicate with an upstream server")] 66 # Specifies that the WSUS server should use Secure Sockets Layer (SSL) via HTTPS to communicate with an upstream server. 67 [Switch]$UseSsl, 68 69[Parameter(Mandatory = $true, HelpMessage = "Specifies the update Id we should import to WSUS", ParameterSetName = "Single")] 70 # Specifies the update Id we should import to WSUS 71 [ValidateNotNullOrEmpty()] 72 [String]$UpdateId, 73 74[Parameter(Mandatory = $true, HelpMessage = "Specifies path to a text file containing a list of update ID's on each line", ParameterSetName = "Multiple")] 75 # Specifies path to a text file containing a list of update ID's on each line. 76 [ValidateNotNullOrEmpty()] 77 [String]$UpdateIdFilePath 78) 79 80Set-StrictMode -Version Latest 81 82# set server options 83$serverOptions = "Get-WsusServer" 84if ($psBoundParameters.containsKey('WsusServer')) { $serverOptions += " -Name $WsusServer -PortNumber $PortNumber" } 85if ($UseSsl) { $serverOptions += " -UseSsl" } 86 87# empty updateID list 88$updateList = @() 89 90# get update id's 91if ($UpdateIdFilePath) { 92 if (Test-Path $UpdateIdFilePath) { 93 foreach ($id in (Get-Content $UpdateIdFilePath)) { 94 $updateList += $id.Trim() 95 } 96 } 97 else { 98 Write-Error "[$UpdateIdFilePath]: File not found" 99 return 100 } 101} 102else { 103 $updateList = @($UpdateId) 104} 105 106# get WSUS server 107Try { 108 Write-Host "Attempting WSUS Connection using $serverOptions... " -NoNewline 109 $server = invoke-expression $serverOptions 110 Write-Host "Connection Successful" 111} 112Catch { 113 Write-Error $_ 114 return 115} 116 117# empty file list 118$FileList = @() 119 120# call ImportUpdateFromCatalogSite on WSUS 121foreach ($uid in $updateList) { 122 Try { 123 Write-Host "Attempting WSUS update import for Update ID: $uid... " -NoNewline 124 $server.ImportUpdateFromCatalogSite($uid, $FileList) 125 Write-Host "Import Successful" 126 } 127 Catch { 128 Write-Error "Failed. $_" 129 } 130}
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
12345678-90ab-cdef-1234-567890abcdef の部分がUPDATEIDかなと思ったのですが違ったようです。
補足
実は、更新プログラムがとても溜まっています。
古いものは2010年リリースとなっているのですが、消すと問題があるのでしょうか。
4万程新旧混ざった更新プログラムがあります。
必要なものだけ残して消したいと思いますが問題ないでしょうか。
拒否と表示されているものはサーバークリーンナップウィザードで消せると書いていましたが、実行するとすぐに接続エラーが出てしまいます。
IISの設定の問題のようですが、チューニングを行い動いてはくれましたが最後までいかないです。
根気よく何度もクリーンナップせよと色々なサイトには書いてありました。
WSUSのDBServerにはきちんと接続できていて、クエリーも正常終了しています。
https://learn.microsoft.com/ja-jp/troubleshoot/mem/configmgr/update-management/reindex-the-wsus-database
このURLにあるscriptは正常動作しているようです。

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。