Last active
April 3, 2020 15:42
-
-
Save briantist/3734447 to your computer and use it in GitHub Desktop.
Install Windows Management Framework core package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set updateSession = CreateObject("Microsoft.Update.Session") | |
Set updateSearcher = updateSession.CreateupdateSearcher() | |
Set searchResult = updateSearcher.Search("IsInstalled=0 and Type='Software'") | |
Set toDL = CreateObject("Microsoft.Update.UpdateColl") | |
For I = 0 To searchResult.Updates.Count-1 | |
Set update = searchResult.Updates.Item(I) | |
For kbidindex = 0 to update.KBArticleIDs.Count-1 | |
kbid = update.KBArticleIDs.Item(kbidindex) | |
If kbid = "968930" or kbid = "951847" Then | |
toDL.Add(update) | |
End If | |
Next | |
Next | |
If toDL.Count = 0 Then | |
Set WshShell = wscript.createobject("wscript.shell") | |
WshShell.Run "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe ""Enable-PSRemoting -Force""", 1, True | |
WScript.Quit -1 | |
End If | |
Set DLer = updateSession.CreateUpdateDownloader() | |
DLer.Updates = toDL | |
DLer.Download() | |
DLdone = False | |
Do | |
allDone = True | |
For I = 0 to toDL.Count - 1 | |
Set update = toDL.Item(I) | |
allDone = allDone and update.IsDownloaded | |
Next | |
DLdone = allDone | |
WScript.Sleep 5000 | |
Loop Until DLdone | |
Set installer = updateSession.CreateUpdateInstaller() | |
installer.Updates = toDL | |
Set installationResult = installer.Install() | |
Set WshShell = wscript.createobject("wscript.shell") | |
WshShell.Run "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe ""Enable-PSRemoting -Force""", 1, True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment