vicgarin Posted April 5, 2015 Posted April 5, 2015 (edited) I have been using this script http://tomtalks.uk/2013/09/list-all-microsoftwindows-updates-with-powershell-sorted-by-kbhotfixid-get-microsoftupdate $wu = new-object -com "Microsoft.Update.Searcher" $totalupdates = $wu.GetTotalHistoryCount() $all = $wu.QueryHistory(0,$totalupdates) # Define a new array to gather output $OutputCollection= @() Foreach ($update in $all) { $string = $update.title $Regex = "KB\d*" $KB = $string | Select-String -Pattern $regex | Select-Object { $_.Matches } $output = New-Object -TypeName PSobject $output | add-member NoteProperty "HotFixID" -value $KB.' $_.Matches '.Value $output | add-member NoteProperty "Title" -value $string $OutputCollection += $output }$OutputCollection | Export-Csv \\somedir\somefile.csv -NoTypeInformation -UseCulturebut it does not list the .NET updates which I installed offline. In VM1 where I downloaded the same updates from Windows Update it lists them using the above script. But in VM2 where I installed them offline it doesn't list them? I used the above script because it also lists all the Office updates. Any help appreciated. Edited April 5, 2015 by vicgarin
DosProbie Posted April 5, 2015 Posted April 5, 2015 The 'wmic' command line tool will list all your .NET installs from command line.wMIC Product Where "Name like '%.NET%'" Get Name, Versionalso if you prefer power shell look over here: https://social.technet.microsoft.com/Forums/en-US/98b7e86c-cd7c-4866-b098-38d7910540bd/wmic-namespacerootcimv2-path-win32product-where-name-like-net-get-version-fails?forum=winserver8setup~DP
Yzöwl Posted April 5, 2015 Posted April 5, 2015 Can you not get those using the software uninstall list?@ECHO OFFFOR %%A IN (\ \WOW6432NODE\) DO (FOR /F "TOKENS=1-2*" %%B IN ( 'REG QUERY HKLM\SOFTWARE%%AMICROSOFT\WINDOWS\CURRENTVERSION\UNINSTALL^ /S /F "MICROSOFT CORPORATION" /D' ) DO IF %%D' EQU ' FOR /F "SKIP=1 TOKENS=2*" %%E IN ( 'REG QUERY %%B /V DISPLAYNAME') DO ECHO;%%F)PAUSE
vicgarin Posted April 5, 2015 Author Posted April 5, 2015 Can you not get those using the software uninstall list?@ECHO OFFFOR %%A IN (\ \WOW6432NODE\) DO (FOR /F "TOKENS=1-2*" %%B IN ( 'REG QUERY HKLM\SOFTWARE%%AMICROSOFT\WINDOWS\CURRENTVERSION\UNINSTALL^ /S /F "MICROSOFT CORPORATION" /D' ) DO IF %%D' EQU ' FOR /F "SKIP=1 TOKENS=2*" %%E IN ( 'REG QUERY %%B /V DISPLAYNAME') DO ECHO;%%F)PAUSE Missing opening '(' after keyword 'for'.At line:1 char:5+ FOR <<<< %%A IN (\ \WOW6432NODE\) DO (FOR /F "TOKENS=1-2*" %%B IN ('REG QUERY HKLM\SOFTWARE%%AMICROSOFT\WINDOWS\CURRENTVERSION\UNINSTALL^ /S /F "MICROSOFT CORPORATION" /D') DO IF %%D' EQU ' FOR /F "SKIP=1 TOKENS=2*" %%E IN ('REG QUERY%%B /V DISPLAYNAME') DO ECHO;%%F) + CategoryInfo : ParserError: (OpenParenToken:TokenId) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingOpenParenthesisAfterKeywordPS C:\Windows\system32>
gunsmokingman Posted April 5, 2015 Posted April 5, 2015 Here is a VBS script that build a HTA with a list of missing and installed updates. The HTA has links called KBNUMBER information that tries to open the download from Microsoft for the KBNUMBERKBList.vbsOption Explicit'-> Makes ShorterDim Vb :Vb = vbCrLf'-> Objects For Script Run TimeDim Act, Fso, CName Set Act = CreateObject("Wscript.Shell") Set Fso = CreateObject("Scripting.FileSystemObject") CName = Act.ExpandEnvironmentStrings("%ComputerName%")'-> Ask If You Want To Use Script Dim A1 :A1 = Act.Popup( _ " Would You Like To Run The Report Updates Script?" & Vb & _ "The Script Will Take Approx 5 Minutes To Be Done." & Vb & _ "If Nothing Is Selected This Will Self Close In 7" & Vb & _ "Seconds And Do Nothing", 7, "Search Updates",4132) If A1 = 7 Or A1 = -1 Then WScript.Quit(1) End If '-> Varibles For Hta OutputDim Hta :Hta = Act.SpecialFolders("Desktop") & "\" & CName & "_KbInfo.hta"Dim Ar :Ar = Chr(160) & Chr(187) & Chr(160)Dim Al :Al = Chr(160) & Chr(171) & Chr(160)Dim Ts'-> Search Objects And VariblesDim SearchResult, Update, UpDateSearcher,UpDateSession Set UpDateSession = CreateObject("Microsoft.Update.Session") Set UpDateSearcher = UpDateSession.CreateUpDateSearcher() Set SearchResult = UpDateSearcher.Search("Type='Software'")'-> Varibles For Count, Loop, Updates Dim C1, I, Kb_C, Kb_M, M1, V1, V2 :C1=0 :M1=0 '-> Loop To List Install And Missing Updates For I = 0 To SearchResult.Updates.Count-1 Set Update = SearchResult.Updates.Item(I) If Update.IsInstalled Then C1 = C1 + 1 : V1 = C1 Kb_C = Kb_C & C1 & "=-=" & Update.Title & "=-=" & Update.Description & Vb Else M1 = M1 + 1 : V2 = M1 Kb_M = Kb_M & M1 & "=-=" & Update.Title & "=-=" & Update.Description & Vb End If Next'-> If There Are No Missing Updates If M1 = 0 Then V2 = "000" Kb_M = "000=-=No Updates Found=-=There Was No Updates Missing" & Vb End If'-> If There Are No Installed Updates If C1 = 0 Then V1 = "000" Kb_C = "000=-=No Updates Found Installed=-=There Was No Updates Found Installed." & Vb End If'-> Build The Hta Report Set TS = Fso.CreateTextFile(Hta) TS.WriteLine "<TITLE>" & CName & "</TITLE>" & Vb & _ "<STYLE Type=""text/css"">" & Vb & _ " Body{Font-Size:9.25pt;Font-Weight:Bold;" & Vb & _ " Font-Family:Segoe Ui,Arial,Tahoma;" & Vb & _ " Color:#000063;BackGround-Color:#fdf7f1;" & Vb & _ " Margin-Top:5;Margin-Bottom:5;Margin-Left:4;Margin-Right:4;" & Vb & _ " Padding-Top:5;Padding-Bottom:5;Padding-Left:4;Padding-Right:4;" & Vb & _ " Text-Align:Left;Vertical-Align:Top;" & Vb & _ " Border-Top:2px Solid #cbc7c3;Border-Bottom:3px Solid #a6a29e;" & Vb & _ " Border-Left:2px Solid #bcb8b4;Border-Right:3px Solid #b2aeaa;}" & Vb & _ " TD.Tx1{Font-Size:8.25pt;Color:#004747;Font-Weight:Bold;Padding-Left:3;Width:70pt;}" & Vb & _ " TD.Tx2{Font-Size:8.25pt;Color:#006969;Font-Weight:Bold;Width:105pt;}" & Vb & _ " P.D1{Font-Size:8.25pt;Color:#1e1e1e;Width:99%;Padding-Left:1;Margin:1pt;}" & Vb & _ " FONT.F1{Font-Size:8.25pt;Color:#004400;Padding-Left:3;Width:17pt;}" & Vb & _ " FONT.F2{Font-Size:8.25pt;Font-Weight:Bold;Color:#000063;Padding-Left:3;}" & Vb & _ "</STYLE>" & Vb & _ "<SCRIPT LANGUAGE='JScript'>window.resizeTo (725,425), window.moveTo (210,175);</SCRIPT>" Ts.WriteLine "<BODY Link='#003535' vLink='#007575' aLink='#003535'>" & Vb & _ "<TABLE ALIGN='CENTER'><TD CLASS='Tx1'>Scan Date Time</TD><TD CLASS='Tx2'>" & _ Ar & Now & "</TD></TABLE>" & Vb & _ "<TABLE ALIGN='CENTER'><TD CLASS='Tx1'>Computer Name</TD><TD CLASS='Tx2'>" & _ Ar & CName & "</TD></TABLE>" & Vb & _ "<TABLE ALIGN='CENTER'><TD CLASS='Tx1'>Install KB</TD><TD CLASS='Tx2'>" & _ Ar & Adz(V1) & "</TD></TABLE>" & Vb & _ "<TABLE ALIGN='CENTER'><TD CLASS='Tx1'>Missing KB</TD><TD CLASS='Tx2'>" & _ Ar & Adz(V2) & "</TD></TABLE><HR Width=97%>" Ts.WriteLine "<TABLE Align='Center'>List Of Missing Updates</TABLE><HR Width=99%>" SortInfo(Kb_M) Ts.WriteLine "<TABLE Align='Center'>List Of Installed Updates</TABLE><HR Width=99%>" SortInfo(Kb_C) Ts.Close'-> Run The Hta Act.Run("mshta.exe " & Chr(34) & Hta & Chr(34)),1,True'/-> Keep Or Delete The Hta Report If MsgBox("Did You Want To Keep The HTA Update Report?" & Vb & _ "Yes To Keep The Hta, No To Delete The Hta.",4132,"Keep Or Delete") = 7 Then Fso.DeleteFile Hta, True End If'-> Function Sort The Info For Display In The Hta Function SortInfo(Arg) Dim Obj, S1, V For Each Obj In Split(Arg,Vb) If Not Obj = "" Then V = Split(Obj,"=-=") S1= Right(V(1),11) If InStr(S1,"(") Then S1 = Replace(S1,"(","") If InStr(S1,")") Then S1 = Replace(S1,")","") If InStr(S1,"-") Then S1 = Replace(S1,"-","") If InStr(S1," ") Then S1 = Replace(S1," ","")'-> Sort The Info For Links And None links If LCase(Left(S1,2)) = "kb" Then Ts.WriteLine "<FONT Class='F1'>" & Al & Adz(V(0)) & Ar & "</FONT>" & Vb & _ "<FONT Class='F2'>" & V(1) & "</FONT>" & Vb &_ "<P Class='D1'> " & V(2) & "</DIV>" & Vb & _ "<DIV ALIGN='CENTER'>" & Vb & _ "<A HREF='http://www.microsoft.com/downloads/results.aspx?pocId=&freetext=" & _ S1 &"&DisplayLang='>" & S1 & " Information</A></DIV><HR Width=99%>" & Vb & Vb Else Ts.WriteLine "<FONT Class='F1'>" & Al & V(0) & Ar & "</FONT>" & Vb &_ "<FONT Class='F2'>" & V(1) & "</FONT>" & Vb &_ "<P Class='D1'> " & V(2) & "</DIV><HR Width=99%>" & Vb & Vb End If End If Next End Function '-> Add Zero To A Number Function Adz(N) If Len(N) = 1 Then N = "00" & N If Len(N) = 2 Then N = "0" & N Adz = N End FunctionRename KbList.vbs.txt to KbList.vbs make activeKbList.vbs.txt
vicgarin Posted April 5, 2015 Author Posted April 5, 2015 Here is a VBS script that build a HTA with a list of missing and installed updates. The HTA has links called KBNUMBER information that tries to open the download from Microsoft for the KBNUMBER The VM where this script is run is offline. Maybe that's why I am getting the below error:
Yzöwl Posted April 5, 2015 Posted April 5, 2015 Missing opening '(' after keyword 'for'.At line:1 char:5+ FOR <<<< %%A IN (\ \WOW6432NODE\) DO (FOR /F "TOKENS=1-2*" %%B IN ('REG QUERY HKLM\SOFTWARE%%AMICROSOFT\WINDOWS\CURRENTVERSION\UNINSTALL^ /S /F "MICROSOFT CORPORATION" /D') DO IF %%D' EQU ' FOR /F "SKIP=1 TOKENS=2*" %%E IN ('REG QUERY%%B /V DISPLAYNAME') DO ECHO;%%F) + CategoryInfo : ParserError: (OpenParenToken:TokenId) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingOpenParenthesisAfterKeywordPS C:\Windows\system32>Could you not have just copied and pasted the seven lines exactly as they are into notepad and saved as anything.cmd?
gunsmokingman Posted April 5, 2015 Posted April 5, 2015 The script uses the Microsoft update object and I have no idea on how it would work in VM environment.
vicgarin Posted April 5, 2015 Author Posted April 5, 2015 (edited) Could you not have just copied and pasted the seven lines exactly as they are into notepad and saved as anything.cmd? When I saved it as .cmd file it works! It lists the .NET security updates KB numbers. Is it possible to filter out the lines which don't have any KB numbers associated with them? Because I am seeing stuff like: EMET 5.2Microsoft Office Shared Setup Metadata MUI (English) 2013... Also is it possible to add all the installed updates into your script? Then I won't have to use the script mentioned in the original post. Thanks for your help. Edited April 5, 2015 by vicgarin
DosProbie Posted April 5, 2015 Posted April 5, 2015 You can also print out a .log file of all your .NET installs (Name and Version) from batch, just Run as administrator.~DP@Echo Off::NetInstalls.cmd (Run As Admin)WMIC /NameSpace:\\Root\Cimv2 Path Win32_Product Where "Name Like '%%.NET%%'" Get Name, Version|Findstr /VI Version > C:\NetInstalls.logPause
vicgarin Posted April 5, 2015 Author Posted April 5, 2015 You can also print out a .log file of all your .NET installs (Name and Version) from batch, just Run as administrator.~DP@Echo Off::NetInstalls.cmd (Run As Admin)WMIC /NameSpace:\\Root\Cimv2 Path Win32_Product Where "Name Like '%%.NET%%'" Get Name, Version|Findstr /VI Version > C:\NetInstalls.logPause What I am trying to achieve is a listing of all the updates with the KB numbers, so I can compare 2 VMs. That is which updates are missing in the offline VM, so I can download and install those manually.
DosProbie Posted April 6, 2015 Posted April 6, 2015 If what you want are the hotfixes with KB's you can also use system info or wmic as well in script for a dated log file and just run as admin.~DP@Echo Off:: KBUpdates.cmd:: ### PRINT ALL INSTALLED KB UPDATES TO DATED LOG FILE..:: Via WmicSet Wusa=%systemdrive%\HotFixes-%date:~10,4%-%date:~4,2%-%date:~7,2%-%date:~0,3%.htmWmic qfe list full /format:htable>%wusa%:: Via SysteminfoFor /F "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%date:~10,4%-%date:~4,2%-%date:~7,2%-%date:~0,3%)Set Wusa_Dt=%mydate%Systeminfo|Find ": KB">nul>> %systemdrive%\UPDATE.LOG.%wusa_Dt%.logPause
Yzöwl Posted April 9, 2015 Posted April 9, 2015 @vicgarin,I have tidied up this topic because I saw no reason to continue down the route I was taking you.I have had access to a Windows 7 Unit this evening and have therefore formulated something which should contain what you needed; (since systeminfo and quickfixengineering didn't include the .NET installs).@ECHO OFFSETLOCALSET _="%TEMP%\_$.TMP"TYPE NUL>%_%FOR /F "TOKENS=2 DELIMS==" %%A IN ('WMIC QFE GET HOTFIXID /VALUE 2^>NUL' ) DO CALL ECHO;[%%A]>>%_%FOR %%A IN (\ \WOW6432NODE\) DO (FOR /F "EOL=E TOKENS=*" %%B IN ( 'REG QUERY HKLM\SOFTWARE%%AMICROSOFT\UPDATES /S /F "KB" /K 2^>NUL' ) DO FIND /I "[%%~nxB]"<%_%>NUL||ECHO;[%%~nxB]>>%_%)SORT<%_%>"%~dp0%COMPUTERNAME%HOTFIXES.TXT"DEL %_%Just run the above on each unit and compare the differences! 1
vicgarin Posted April 9, 2015 Author Posted April 9, 2015 (edited) @vicgarin,I have tidied up this topic because I saw no reason to continue down the route I was taking you.I have had access to a Windows 7 Unit this evening and have therefore formulated something which should contain what you needed; (since systeminfo and quickfixengineering didn't include the .NET installs).@ECHO OFFSETLOCALSET _="%TEMP%\_$.TMP"TYPE NUL>%_%FOR /F "TOKENS=2 DELIMS==" %%A IN ('WMIC QFE GET HOTFIXID /VALUE 2^>NUL' ) DO CALL ECHO;[%%A]>>%_%FOR %%A IN (\ \WOW6432NODE\) DO (FOR /F "EOL=E TOKENS=*" %%B IN ( 'REG QUERY HKLM\SOFTWARE%%AMICROSOFT\UPDATES /S /F "KB" /K 2^>NUL' ) DO FIND /I "[%%~nxB]"<%_%>NUL||ECHO;[%%~nxB]>>%_%)SORT<%_%>"%~dp0%COMPUTERNAME%HOTFIXES.TXT"DEL %_%Just run the above on each unit and compare the differences! Thank you. The above code does the trick! Edit: see below Edited May 30, 2015 by vicgarin
vicgarin Posted May 28, 2015 Author Posted May 28, 2015 @vicgarin,I have tidied up this topic because I saw no reason to continue down the route I was taking you.I have had access to a Windows 7 Unit this evening and have therefore formulated something which should contain what you needed; (since systeminfo and quickfixengineering didn't include the .NET installs).@ECHO OFFSETLOCALSET _="%TEMP%\_$.TMP"TYPE NUL>%_%FOR /F "TOKENS=2 DELIMS==" %%A IN ('WMIC QFE GET HOTFIXID /VALUE 2^>NUL' ) DO CALL ECHO;[%%A]>>%_%FOR %%A IN (\ \WOW6432NODE\) DO (FOR /F "EOL=E TOKENS=*" %%B IN ( 'REG QUERY HKLM\SOFTWARE%%AMICROSOFT\UPDATES /S /F "KB" /K 2^>NUL' ) DO FIND /I "[%%~nxB]"<%_%>NUL||ECHO;[%%~nxB]>>%_%)SORT<%_%>"%~dp0%COMPUTERNAME%HOTFIXES.TXT"DEL %_%Just run the above on each unit and compare the differences! I reran the above code, but it does not seem to list all the updates? For example MS Office updates? Also is it possible to also print out the title of the KB next to the KB number. This way I can exclude stuff like Windows Defender updates before comparing the 2 lists. Again thanks for helping.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now