喷子特朗普

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

1.原因分析:Windows11的底层版本是Windows10,Windows10和Windows11的区别,以及22H2和23H2子版本的区别,只能通过10.0后面的数字来辨别。

而WSUS显示的是操作系统的底层版本,微软一直未更新WSUS。

 

在Windows11查看当前操作系统版本,如下:

 

2.解决思路:通过修改WSUS后台数据库,将子版本号与系统版本建立关联,如10.0.25398等于Windows11 23H2。

将以下代码生成.ps文件,在WSUS服务器上执行(安装NuGet和SqlServer管理器阶段,必须联网)

  1 # Update tbComputerTargetDetail for WSUS to add more details in OSDescription field (based on https://www.wsus.de/windows-editionen-anzeigen/)
  2 # See also https://server-essentials.com/support/windows-10-vista-wsus-not-updating
  3 # See also https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-wusp/5f216289-0876-4dc3-ad85-e1d61a9e7ce1#Appendix_A_13
  4 
  5 Param (
  6     [Parameter()][String]$SQLServerInstance = '\\.\pipe\MICROSOFT##WID\tsql\query',
  7     [Parameter()][String]$Encrypt = 'Optional'
  8 )
  9 
 10 # Setup NuGet
 11 Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
 12 
 13 # Requires SqlServer PowerShell module to be installed
 14 Install-Module -Name SqlServer -AllowClobber -Force
 15 
 16 $ClientProductVersions = @(
 17     # Based on https://learn.microsoft.com/en-us/windows/release-health/release-information
 18     @{
 19         ProductVersion = ' 8'
 20         OSMajorVersion = 6
 21         OSMinorVersion = 2
 22         OSBuildNumber = 9200
 23     }
 24     @{
 25         ProductVersion = ' 8.1'
 26         OSMajorVersion = 6
 27         OSMinorVersion = 3
 28         OSBuildNumber = 9600
 29     }
 30     @{
 31         ProductVersion = ' 10'
 32         ProductRelease = ' 1507'
 33         OSMajorVersion = 10
 34         OSMinorVersion = 0
 35         OSBuildNumber = 10240
 36     }
 37     @{
 38         ProductVersion = ' 10'
 39         ProductRelease = ' 1511'
 40         OSMajorVersion = 10
 41         OSMinorVersion = 0
 42         OSBuildNumber = 10586
 43     }
 44     @{
 45         ProductVersion = ' 10'
 46         ProductRelease = ' 1607'
 47         OSMajorVersion = 10
 48         OSMinorVersion = 0
 49         OSBuildNumber = 14393
 50     }
 51     @{
 52         ProductVersion = ' 10'
 53         ProductRelease = ' 1703'
 54         OSMajorVersion = 10
 55         OSMinorVersion = 0
 56         OSBuildNumber = 15063
 57     }
 58     @{
 59         ProductVersion = ' 10'
 60         ProductRelease = ' 1709'
 61         OSMajorVersion = 10
 62         OSMinorVersion = 0
 63         OSBuildNumber = 16299
 64     }
 65     @{
 66         ProductVersion = ' 10'
 67         ProductRelease = ' 1803'
 68         OSMajorVersion = 10
 69         OSMinorVersion = 0
 70         OSBuildNumber = 17134
 71     }
 72     @{
 73         ProductVersion = ' 10'
 74         ProductRelease = ' 1809'
 75         OSMajorVersion = 10
 76         OSMinorVersion = 0
 77         OSBuildNumber = 17763
 78     }
 79     @{
 80         ProductVersion = ' 10'
 81         ProductRelease = ' 1903'
 82         OSMajorVersion = 10
 83         OSMinorVersion = 0
 84         OSBuildNumber = 18362
 85     }
 86     @{
 87         ProductVersion = ' 10'
 88         ProductRelease = ' 1909'
 89         OSMajorVersion = 10
 90         OSMinorVersion = 0
 91         OSBuildNumber = 18363
 92     }
 93     @{
 94         ProductVersion = ' 10'
 95         ProductRelease = ' 2004'
 96         OSMajorVersion = 10
 97         OSMinorVersion = 0
 98         OSBuildNumber = 19041
 99     }
100     @{
101         ProductVersion = ' 10'
102         ProductRelease = ' 20H2'
103         OSMajorVersion = 10
104         OSMinorVersion = 0
105         OSBuildNumber = 19042
106     }
107     @{
108         ProductVersion = ' 10'
109         ProductRelease = ' 21H1'
110         OSMajorVersion = 10
111         OSMinorVersion = 0
112         OSBuildNumber = 19043
113     }
114     @{
115         ProductVersion = ' 10'
116         ProductRelease = ' 21H2'
117         OSMajorVersion = 10
118         OSMinorVersion = 0
119         OSBuildNumber = 19044
120     }
121     @{
122         ProductVersion = ' 10'
123         ProductRelease = ' 22H2'
124         OSMajorVersion = 10
125         OSMinorVersion = 0
126         OSBuildNumber = 19045
127     }
128     # Based on https://learn.microsoft.com/en-us/windows/release-health/windows11-release-information
129     @{
130         ProductVersion = ' 11'
131         ProductRelease = ' 21H2'
132         OSMajorVersion = 10
133         OSMinorVersion = 0
134         OSBuildNumber = 22000
135     }
136     @{
137         ProductVersion = ' 11'
138         ProductRelease = ' 22H2'
139         OSMajorVersion = 10
140         OSMinorVersion = 0
141         OSBuildNumber = 22621
142     }
143     @{
144         ProductVersion = ' 11'
145         ProductRelease = ' 23H2'
146         OSMajorVersion = 10
147         OSMinorVersion = 0
148         OSBuildNumber = 22631
149     }
150     @{
151         ProductVersion = ' 11'
152         ProductRelease = ' 24H2'
153         OSMajorVersion = 10
154         OSMinorVersion = 0
155         OSBuildNumber = 26100
156     }
157 )
158 
159 $ServerProductVersions = @(
160     # Based on https://learn.microsoft.com/en-us/windows/release-health/windows-server-release-info
161     @{
162         ProductVersion = ' 2012'
163         OSMajorVersion = 6
164         OSMinorVersion = 2
165         OSBuildNumber = 9200
166     }
167     @{
168         ProductVersion = ' 2012 R2'
169         OSMajorVersion = 6
170         OSMinorVersion = 3
171         OSBuildNumber = 9600
172     }
173     @{
174         ProductVersion = ' 2016'
175         OSMajorVersion = 10
176         OSMinorVersion = 0
177         OSBuildNumber = 14393
178     }
179     @{
180         ProductVersion = ', version 1709'
181         OSMajorVersion = 10
182         OSMinorVersion = 0
183         OSBuildNumber = 16299
184     }
185     @{
186         ProductVersion = ', version 1803'
187         OSMajorVersion = 10
188         OSMinorVersion = 0
189         OSBuildNumber = 17134
190     }
191     @{
192         ProductVersion = ' 2019'
193         OSMajorVersion = 10
194         OSMinorVersion = 0
195         OSBuildNumber = 17763
196     }
197     @{
198         ProductVersion = ', version 1903'
199         OSMajorVersion = 10
200         OSMinorVersion = 0
201         OSBuildNumber = 18362
202     }
203     @{
204         ProductVersion = ', version 1909'
205         OSMajorVersion = 10
206         OSMinorVersion = 0
207         OSBuildNumber = 18363
208     }
209     @{
210         ProductVersion = ', version 2004'
211         OSMajorVersion = 10
212         OSMinorVersion = 0
213         OSBuildNumber = 19041
214     }
215     @{
216         ProductVersion = ', version 20H2'
217         OSMajorVersion = 10
218         OSMinorVersion = 0
219         OSBuildNumber = 19042
220     }
221     @{
222         ProductVersion = ' 2022'
223         OSMajorVersion = 10
224         OSMinorVersion = 0
225         OSBuildNumber = 20348
226     }
227     @{
228         ProductVersion = ', version 23H2'
229         OSMajorVersion = 10
230         OSMinorVersion = 0
231         OSBuildNumber = 25398
232     }
233     @{
234         ProductVersion = ' 2025'
235         OSMajorVersion = 10
236         OSMinorVersion = 0
237         OSBuildNumber = 26100
238     }
239 )
240 
241 $OSDescriptions = @(
242     @{
243         ProductName = 'Windows'
244         ProductVersions = $ClientProductVersions
245         ProductTypes = @(
246             # Based on https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-operatingsystem
247             # Based on https://learn.microsoft.com/en-us/mem/intune/fundamentals/filters-device-properties
248             # Based on https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getproductinfo
249             @{
250                 ProductEdition = ' S'
251                 NewProductTypes = @(178)
252             }
253             @{
254                 ProductEdition = ' S N'
255                 NewProductTypes = @(179)
256             }
257             @{
258                 ProductEdition = ' Pro N'
259                 NewProductTypes = @(49)
260             }
261             @{
262                 ProductEdition = ' SE'
263                 NewProductTypes = @(203)
264             }
265             @{
266                 ProductEdition = ' SE N'
267                 NewProductTypes = @(202)
268             }
269             @{
270                 ProductEdition = ' Home'
271                 NewProductTypes = @(101, 111)
272             }
273             @{
274                 ProductEdition = ' Home China'
275                 NewProductTypes = @(99)
276             }
277             @{
278                 ProductEdition = ' Home N'
279                 NewProductTypes = @(98)
280             }
281             @{
282                 ProductEdition = ' Home Single Language'
283                 NewProductTypes = @(100)
284             }
285             @{
286                 ProductEdition = ' Education'
287                 NewProductTypes = @(121)
288             }
289             @{
290                 ProductEdition = ' Education N'
291                 NewProductTypes = @(122)
292             }
293             @{
294                 ProductEdition = ' Enterprise'
295                 NewProductTypes = @(4)
296             }
297             @{
298                 ProductEdition = ' Enterprise Evaluation'
299                 NewProductTypes = @(72)
300             }
301             @{
302                 ProductEdition = ' Enterprise G'
303                 NewProductTypes = @(171)
304             }
305             @{
306                 ProductEdition = ' Enterprise G N'
307                 NewProductTypes = @(172)
308             }
309             @{
310                 ProductEdition = ' Enterprise N'
311                 NewProductTypes = @(27)
312             }
313             @{
314                 ProductEdition = ' Enterprise N Evaluation'
315                 NewProductTypes = @(84)
316             }
317             @{
318                 ProductEdition = ' Enterprise LTSC'
319                 NewProductTypes = @(125)
320             }
321             @{
322                 ProductEdition = ' Enterprise LTSC Evaluation'
323                 NewProductTypes = @(129)
324             }
325             @{
326                 ProductEdition = ' Enterprise LTSC N'
327                 NewProductTypes = @(126)
328             }
329             @{
330                 ProductEdition = ' Enterprise LTSC N Evaluation'
331                 NewProductTypes = @(130)
332             }
333             @{
334                 ProductEdition = ' Holographic'
335                 NewProductTypes = @(135)
336             }
337             @{
338                 ProductEdition = ' Holographic for Business'
339                 NewProductTypes = @(136)
340             }
341             @{
342                 ProductEdition = ' IoT Core'
343                 NewProductTypes = @(123)
344             }
345             @{
346                 ProductEdition = ' IoT Core Commercial'
347                 NewProductTypes = @(131)
348             }
349             @{
350                 ProductEdition = ' IoT Enterprise'
351                 NewProductTypes = @(188)
352             }
353             @{
354                 ProductEdition = ' IoT Enterprise LTSC'
355                 NewProductTypes = @(191)
356             }
357             @{
358                 ProductEdition = ' Mobile'
359                 NewProductTypes = @(104)
360             }
361             @{
362                 ProductEdition = ' Mobile Enterprise'
363                 NewProductTypes = @(133)
364             }
365             @{
366                 ProductEdition = ' Team'
367                 NewProductTypes = @(119)
368             }
369             @{
370                 ProductEdition = ' Pro'
371                 NewProductTypes = @(48)
372             }
373             @{
374                 ProductEdition = ' Pro Education'
375                 NewProductTypes = @(164)
376             }
377             @{
378                 ProductEdition = ' Pro Education N'
379                 NewProductTypes = @(165)
380             }
381             @{
382                 ProductEdition = ' Pro for Workstations'
383                 NewProductTypes = @(161)
384             }
385             @{
386                 ProductEdition = ' Pro for Workstations N'
387                 NewProductTypes = @(162)
388             }
389             @{
390                 ProductEdition = ' Pro China'
391                 NewProductTypes = @(139)
392             }
393             @{
394                 ProductEdition = ' Pro Single Language'
395                 NewProductTypes = @(138)
396             }
397             @{
398                 ProductEdition = ' Enterprise multi-session'
399                 NewProductTypes = @(175)
400             }
401         )
402     }
403     @{
404         ProductName = 'Windows RT'
405         ProductVersions = $ClientProductVersions
406         ProductTypes = @(
407             @{
408                 ProductEdition = ''
409                 NewProductTypes = @(97)
410             }
411         )
412     }
413     @{
414         ProductName = 'Windows Server'
415         ProductVersions = $ServerProductVersions
416         ProductTypes = @(
417             # Based on https://learn.microsoft.com/en-us/dotnet/api/microsoft.powershell.commands.operatingsystemsku
418             @{
419                 ProductEdition= ' Standard'
420                 NewProductTypes = @(7, 13)
421             }
422             @{
423                 ProductEdition= ' Standard Evaluation'
424                 NewProductTypes = @(79, 160)
425             }
426             @{
427                 ProductEdition= ' Datacenter'
428                 NewProductTypes = @(8, 12)
429             }
430             @{
431                 ProductEdition= ' Datacenter Evaluation'
432                 NewProductTypes = @(80, 159)
433             }
434             @{
435                 ProductEdition= ' Datacenter: Azure Edition'
436                 NewProductTypes = @(407)
437             }
438             @{
439                 ProductEdition= ' Foundation'
440                 NewProductTypes = @(33)
441             }
442             @{
443                 ProductEdition = ' Essentials'
444                 NewProductTypes = @(50)
445             }
446         )
447     }
448     @{
449         ProductName = 'Microsoft Hyper-V Server'
450         ProductVersions = $ServerProductVersions
451         ProductTypes = @(
452             @{
453                 ProductEdition = ''
454                 NewProductTypes = @(42)
455             }
456         )
457     }
458 )
459 
460 $SqlcmdQuery = "USE [SUSDB]"
461 
462 foreach ($OSDescription in $OSDescriptions) {
463     foreach ($ProductVersion in $OSDescription.ProductVersions) {
464         foreach ($ProductType in $OSDescription.ProductTypes) {
465             foreach ($NewProductType in $ProductType.NewProductTypes) {
466                 $FullOSDescription = "$($OSDescription.ProductName)$($ProductVersion.ProductVersion)$($ProductType.ProductEdition)$($ProductVersion.ProductRelease)"
467                 $SqlcmdQuery += "`r`n" + (('UPDATE [dbo].[tbComputerTargetDetail]',
468                 "SET [OSDescription] = `'$FullOSDescription`'",
469                 'WHERE',
470                 "[OSMajorVersion] = $($ProductVersion.OSMajorVersion)",
471                 'AND',
472                 "[OSMinorVersion] = $($ProductVersion.OSMinorVersion)",
473                 'AND',
474                 "[OSBuildNumber] = $($ProductVersion.OSBuildNumber)",
475                 'AND',
476                 "[NewProductType] = $($NewProductType)",
477                 'AND',
478                 "( [OSDescription] <> `'$FullOSDescription`' OR [OSDescription] IS NULL )") -join "`r`n")
479             }
480         }
481     }
482 }
483 
484 Invoke-Sqlcmd -ServerInstance $SQLServerInstance -Encrypt $Encrypt -Query $SqlcmdQuery -Verbose 4>&1 | Tee-Object -FilePath "$env:ProgramFiles\Update Services\Update-WSUSComputerOperatingSystems.log"

 

posted on 2025-06-18 11:11  喷子特朗普  阅读(383)  评论(0)    收藏  举报