Windows
Get-HotFix 未返回所有已安裝的 KB
我在
Get-HotFix
Windows Server 2012 上的命令沒有返回所有已安裝的 KB 時遇到問題,與查詢時 Windows Update 所說的實際安裝在伺服器上的內容相比。Get-HotFix 腳本:
Get-HotFix | Select-Object HotFixID | Where-Object { $_.HotFixId.ToUpper().StartsWith("KB") } | ForEach-Object { Write-Output "PACKAGE:$($_.HotFixId)" }
Windows 更新腳本
$Session = New-Object -ComObject Microsoft.Update.Session $Searcher = $Session.CreateUpdateSearcher() $Searcher.ServerSelection = 2 $InstalledUpdates = $Searcher.Search("IsInstalled=1") ForEach ($Update in $InstalledUpdates.Updates) { Foreach ($KB_ID in $Update.KBArticleIDs) { Write-Output "PACKAGE_WUA:KB$($KB_ID)|$($Update.Identity.UpdateID)" } }
Get-HotFix 腳本的輸出:
PACKAGE:KB3191564 PACKAGE:KB2868626 PACKAGE:KB2883200 PACKAGE:KB2887595 PACKAGE:KB2903939 PACKAGE:KB2911106 PACKAGE:KB2919355 PACKAGE:KB2919394 PACKAGE:KB2920189 PACKAGE:KB2928680 PACKAGE:KB2934520 PACKAGE:KB2938066 PACKAGE:KB2954879 PACKAGE:KB2955164 PACKAGE:KB2961908 PACKAGE:KB2967917 PACKAGE:KB2975061 PACKAGE:KB2977765 PACKAGE:KB2978041 PACKAGE:KB2978126 PACKAGE:KB2989930 PACKAGE:KB2999226 PACKAGE:KB3000483 PACKAGE:KB3000850 PACKAGE:KB3003057 PACKAGE:KB3004365 PACKAGE:KB3004545 PACKAGE:KB3012702 PACKAGE:KB3013172 PACKAGE:KB3013769 PACKAGE:KB3013791 PACKAGE:KB3013816 PACKAGE:KB3014442 PACKAGE:KB3019978 PACKAGE:KB3021910 PACKAGE:KB3023222 PACKAGE:KB3023266 PACKAGE:KB3024751 PACKAGE:KB3024755 PACKAGE:KB3030947 PACKAGE:KB3033446 PACKAGE:KB3035126 PACKAGE:KB3036612 PACKAGE:KB3037579 PACKAGE:KB3038002 PACKAGE:KB3042085 PACKAGE:KB3044374 PACKAGE:KB3044673 PACKAGE:KB3045634 PACKAGE:KB3045685 PACKAGE:KB3045717 PACKAGE:KB3045719 PACKAGE:KB3045755 PACKAGE:KB3045999 PACKAGE:KB3046017 PACKAGE:KB3046737 PACKAGE:KB3054169 PACKAGE:KB3054203 PACKAGE:KB3054256 PACKAGE:KB3054464 PACKAGE:KB3055323 PACKAGE:KB3055343 PACKAGE:KB3055642 PACKAGE:KB3059317 PACKAGE:KB3060793 PACKAGE:KB3061512 PACKAGE:KB3063843 PACKAGE:KB3064209 PACKAGE:KB3065822 PACKAGE:KB3065988 PACKAGE:KB3068708 PACKAGE:KB3071756 PACKAGE:KB3074228 PACKAGE:KB3074548 PACKAGE:KB3075853 PACKAGE:KB3077715 PACKAGE:KB3078071 PACKAGE:KB3078405 PACKAGE:KB3078676 PACKAGE:KB3080149 PACKAGE:KB3082089 PACKAGE:KB3084135 PACKAGE:KB3084905 PACKAGE:KB3086255 PACKAGE:KB3087137 PACKAGE:KB3091297 PACKAGE:KB3094486 PACKAGE:KB3095701 PACKAGE:KB3097997 PACKAGE:KB3098779 PACKAGE:KB3099834 PACKAGE:KB3100473 PACKAGE:KB3102429 PACKAGE:KB3102467 PACKAGE:KB3103616 PACKAGE:KB3103696 PACKAGE:KB3103709 PACKAGE:KB3109103 PACKAGE:KB3109976 PACKAGE:KB3110329 PACKAGE:KB3112148 PACKAGE:KB3112336 PACKAGE:KB3115224 PACKAGE:KB3118401 PACKAGE:KB3121261 PACKAGE:KB3122654 PACKAGE:KB3123245 PACKAGE:KB3124275
Windows 更新腳本的輸出:
PACKAGE_WUA:KB925673|07609d43-d518-4e77-856e-d1b316d1b8a8 PACKAGE_WUA:KB2538243|729a0dcb-df9e-4d02-b603-ed1aee074428 PACKAGE_WUA:KB3023266|8ffb7a9e-cafe-456f-a219-13b3e7a56ed2 PACKAGE_WUA:KB3019978|2628719c-4abd-46e2-93e8-fe53c19c3117 PACKAGE_WUA:KB3000483|4361108d-d09b-4c4d-8b2f-f1167f7b8c57 PACKAGE_WUA:KB3035126|3fea2186-fb39-41f1-9214-55a5bb5552e6 PACKAGE_WUA:KB2919355|8452bac0-bf53-4fbd-915d-499de08c338b PACKAGE_WUA:KB3045755|36696f1a-eb7a-48db-a69b-fae68b1fbf58 PACKAGE_WUA:KB3045999|4678f8b9-0b81-4f8b-853f-4adfed9262a6 PACKAGE_WUA:KB3045685|5d50743b-e648-4acc-8986-a7bc5aa53f71 PACKAGE_WUA:KB3055642|02ee413c-7bbb-4fe0-bd97-9e931a2208e1 PACKAGE_WUA:KB3059317|8bb29af2-47b2-439e-b999-3176c23a8e8b PACKAGE_WUA:KB3061512|54110383-c46c-4424-a8ef-9cd6b7a20025 PACKAGE_WUA:KB3004365|fb95c1c8-de23-4089-ae29-fd3351d55421 PACKAGE_WUA:KB3046017|4b7876f0-b962-4c4c-9e45-fe35b0c801ce PACKAGE_WUA:KB3071756|f7c02df0-0cb8-4a56-b367-7efd5c9bc9ac PACKAGE_WUA:KB3082089|7c5f1dad-2f35-4120-b4ad-c5947edf0567 PACKAGE_WUA:KB3084135|04f04253-f803-43b8-8b37-6841c614dd9f PACKAGE_WUA:KB3086255|c848ed4a-5e2e-43dc-bd1b-cb2f717e90cd PACKAGE_WUA:KB3109103|d928f50f-191e-4858-b546-acda983da182 PACKAGE_WUA:KB3110329|27ae312b-1b1a-4f18-a574-3dfe46244d3a PACKAGE_WUA:KB3126593|3ce61d87-7153-4540-a74b-fd0065edfdde PACKAGE_WUA:KB3133043|1bc49ccc-409b-4d07-93b7-cea850ea0d78 PACKAGE_WUA:KB3126041|aa793ff1-f4b7-42b1-9f24-6f11b50f952c PACKAGE_WUA:KB3126434|6b6a5779-3fe5-4789-aba6-0c3e9b802b37 PACKAGE_WUA:KB3126587|214b1f40-24ed-4dae-9e76-237763c5c8ca PACKAGE_WUA:KB3135998|8069b13a-3bf0-4e14-a80b-d5cd3acc42ed PACKAGE_WUA:KB3139398|dd382658-effd-4e24-abca-877e1915bf6d PACKAGE_WUA:KB3139914|06eae584-188d-4a35-805a-ef98beddcd3d PACKAGE_WUA:KB3146723|209e2d1e-330f-4dcc-b705-5999c2f38385 PACKAGE_WUA:KB3156059|05ba4c3c-81c2-4c19-9899-a4a18716cddb PACKAGE_WUA:KB3155784|20d1a457-eca7-488d-a870-96d7374cb436 PACKAGE_WUA:KB3159398|d9f4e1b5-4477-4d83-8c27-111ce0e88dd8 PACKAGE_WUA:KB3161949|67a00639-09a1-4c5f-83ff-394e7601fc03 PACKAGE_WUA:KB3162343|ba0f75ff-19c3-4cbd-a3f3-ef5b5c0f88bf PACKAGE_WUA:KB3172729|cdde339c-ebdb-4a16-add4-fb196a5053a8 PACKAGE_WUA:KB3175024|77798aee-dc0e-409a-875c-7134c8a93766 PACKAGE_WUA:KB3178539|e90f9283-7304-4a98-a5ec-98bd2a3163e7 PACKAGE_WUA:KB3205400|ff4c348a-c6c2-4bbc-af33-01ef3ae1cc6e PACKAGE_WUA:KB4012213|80bc2b42-a953-4096-8595-130e9a9c9fb9 PACKAGE_WUA:KB4015547|79629e4e-67eb-438d-9420-17c673012731 PACKAGE_WUA:KB4019213|2913676b-33a1-4557-9160-f36bfed5f294 PACKAGE_WUA:KB4019111|2e2dc8c8-c324-4968-9461-1c5c6f1190c1 PACKAGE_WUA:KB4022717|7b6c010d-36ea-4bb4-9d06-9e44c1235690 PACKAGE_WUA:KB4025333|a8091733-a526-4480-afe7-72a1b3385439 PACKAGE_WUA:KB4034672|1d84c38c-d2dd-4ad8-acd7-19d9391de17f PACKAGE_WUA:KB4038793|9516efa8-6493-43de-979c-ebf2aa89aa69 PACKAGE_WUA:KB4041687|e36e24fc-789e-483f-bb72-01a3ec3eea74 PACKAGE_WUA:KB4048961|896142dc-9329-403d-98e0-229567e995d9 PACKAGE_WUA:KB4054522|89bb3c1a-4825-4ae3-a42f-ad0ae8c86c1a PACKAGE_WUA:KB4056898|29159163-0da5-456d-92a5-9bd853a401ae PACKAGE_WUA:KB4055271|0f6efea5-e7fe-4bab-80fa-4033e4a017ab PACKAGE_WUA:KB4074597|f5df629a-edb7-49f1-946d-18e4f0a860f0 PACKAGE_WUA:KB4088879|913c1d08-eb63-4b74-aeff-a476d1fbaa2c PACKAGE_WUA:KB4093115|33be9fcf-aef5-44fd-8164-e6b8baa88549 PACKAGE_WUA:KB4103715|196f3a64-83fb-4123-a71b-3e7aa0534b4a PACKAGE_WUA:KB4099639|041c9d83-7a16-4e5d-8f2b-35d5cca0fc62 PACKAGE_WUA:KB4284878|45636cfd-ab6b-4db5-a310-712f3663eae6 PACKAGE_WUA:KB4338824|007ce1f3-3a12-40ef-8389-322068b780a7 PACKAGE_WUA:KB4340006|1d638098-af3d-4ca5-84e1-db9cb0e82ae4 PACKAGE_WUA:KB4339284|d91c89a6-0ef2-4b57-961d-f3f657de9d66 PACKAGE_WUA:KB4343888|ed4981c9-7aa7-4e1f-bdd5-b43d2afae17a PACKAGE_WUA:KB4345681|c601cf7a-ba23-4d6d-bcdc-c61c258e7f1f PACKAGE_WUA:KB4457143|b4e784a4-9907-4d25-90ef-858bcafcf450 PACKAGE_WUA:KB4462941|07cf0ca5-397c-46ee-9093-b1e5dbce59bb PACKAGE_WUA:KB4462901|cecc9666-c679-4104-9ba0-bfe206d181a5 PACKAGE_WUA:KB4468323|03a8098b-7740-40da-9082-00ea285035be PACKAGE_WUA:KB4471322|39654137-cb30-429e-b09a-2c39055716c1 PACKAGE_WUA:KB4471983|0fcc811c-48de-4c15-8240-5ccdb8171d8b PACKAGE_WUA:KB4480964|45e80aae-4277-4c87-bd05-5cc8c6dd672e PACKAGE_WUA:KB4487123|aa180d6a-6b08-4f8b-8e93-682de0657164 PACKAGE_WUA:KB4487080|e69d46be-4fe0-4d50-baf6-6091109d90ab PACKAGE_WUA:KB4487028|0b256bc7-170d-4ee7-a993-8e9fac37a589 PACKAGE_WUA:KB4486459|adbc9c77-f9ba-4224-8b5c-4ae453898c2b PACKAGE_WUA:KB4489883|dded804a-129f-4644-899c-e49ccd2bad2c PACKAGE_WUA:KB4490128|c49cf4bb-325d-4752-ae32-33e053fabaf2 PACKAGE_WUA:KB890830|c991073f-ca3e-467d-b5a0-c8574b289b96 PACKAGE_WUA:KB4493435|94debd3d-b7b7-42e0-9645-11a4e8c83772 PACKAGE_WUA:KB4493467|8693f170-0aea-4539-bc72-feffa6e947ba PACKAGE_WUA:KB4493446|a946a42f-5514-49bd-8a5c-42bf6354d8e4
如您所見,
Get-HotFix
命令輸出中缺少以下 KB (61):KB925673, KB2538243, KB3126593, KB3133043, KB3126041, KB3126434, KB3126587, KB3135998, KB3139398, KB3139914, KB3146723, KB3156059, KB3155784, KB3159398, KB3161949, KB3162343, KB3172729, KB3175024, KB3178539, KB3205400, KB4012213, KB4015547, KB4019213, KB4019111, KB4022717, KB4025333, KB4034672, KB4038793, KB4041687, KB4048961, KB4054522, KB4056898, KB4055271, KB4074597, KB4088879, KB4093115, KB4103715, KB4099639, KB4284878, KB4338824, KB4340006, KB4339284, KB4343888, KB4345681, KB4457143, KB4462941, KB4462901, KB4468323, KB4471322, KB4471983, KB4480964, KB4487123, KB4487080, KB4487028, KB4486459, KB4489883, KB4490128, KB890830, KB4493435, KB4493467, KB4493446
例如,最後一個 (KB4493446) 是 2019 年 4 月的累積值。
我的問題是:
- 是什麼使得它
Get-HotFix
返回的 KB 比查詢 Windows 更新時少?- 什麼是無需連接到網際網路即可檢索所有已安裝 KB 的好方法?
您是否嘗試過使用部署映像服務和管理 (DISM) ?
https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/what-is-dism
您可以直接使用 dism :
dism /online /get-packages
/online
並不意味著您需要網際網路,而只是針對目前系統。如果您更喜歡 powershell,還可以使用 Powershell DISM 包裝器:
Get-WindowsPackage -Online
https://docs.microsoft.com/fr-fr/previous-versions/windows/powershell-scripting/dn376488(v=wps.620)