teratail header banner
teratail header banner
質問するログイン新規登録

質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.30%
Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

Windows Server

Windows Serverとは、Microsoft社のサーバ用オペレーティングシステムの総称です。 企業内ネットワークなどで利用されるサーバ機へ導入することを想定して開発されているため高い安定性があり、 管理機能を提供するソフトウェアが多く含まれています。

Q&A

1回答

510閲覧

WSUSの個別インポートについて

eri00012

総合スコア0

Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

Windows Server

Windows Serverとは、Microsoft社のサーバ用オペレーティングシステムの総称です。 企業内ネットワークなどで利用されるサーバ機へ導入することを想定して開発されているため高い安定性があり、 管理機能を提供するソフトウェアが多く含まれています。

0グッド

0クリップ

投稿2024/05/14 15:30

0

0

実現したいこと

分類でドライバーにチェックを入れずに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は正常動作しているようです。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

このスクリプトですが、スクリプトの先頭に使い方が書いてありますね…PowerShell初心者とお見受けします。
上記スクリプトを、ファイルとして例えば”ImportUpdateToWSUS.ps1”という名前で保存してから使う仕様になっています。
例えば、WSUSサーバー上で実行し、インポートするUpdateIDが"12345678-90ab-cdef-1234-567890abcdef"だった場合は以下のようになります。

PowerShell

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

その他詳しい使い方はこちらのサイトに記載がありますね。

投稿2024/05/20 11:24

Takeda_Kazuhito

総合スコア379

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.30%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問