Jump to content

need help with .js script to hide updates


Recommended Posts

var updateSession = WScript.CreateObject("Microsoft.Update.Session");
var updateSearcher = updateSession.CreateUpdateSearcher();
updateSearcher.Online = false;

// this part must be changed? this is the language pack section. I want to search the entire database that isn't installed and filter by KB###### rather than category.
var searchResult = updateSearcher.Search("CategoryIDs Contains 'cd5ffd1e-e932-4e3a-bf74-18bf0b1bbd83' And IsInstalled=0");

for(var i=0; i<searchResult.Updates.Count; i++){
var update = searchResult.Updates.Item(i);
WScript.echo("Hiding:" + update.Title);
update.IsHidden = true;
}

I can't work out how to modify this script so that it will hide certain specific updates filtered by KBtitle

such as KB2483139 KB915597 KB971033 KB890830

actually just these 4.

Thanks

Link to comment
Share on other sites

  • 1 month later...

This is vbs which works for me. If you can convert to js then share with the rest of the world that would be nice

Function WuaVersion 'get current WUA version
Dim oAgentInfo, ProductVersion
On Error Resume Next
Err.Clear
Set oAgentInfo = CreateObject("Microsoft.Update.AgentInfo")
If ErrNum = 0 Then
WuaVersion = oAgentInfo.GetInfo("ProductVersionString")
Else
Wscript.Echo "Error getting WUA version."
WuaVersion = 0 'calling code can interpret 0 as an error.
End If
On Error Goto 0
End Function

msgbox(WuaVersion)
if WuaVersion <> "0" then
Set ServiceManager = CreateObject("Microsoft.Update.ServiceManager")
ServiceManager.ClientApplicationID = "My App"

'add the Microsoft Update Service, GUID
Set NewUpdateService = ServiceManager.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"")
end if


'ServerSelection values
ssDefault = 0
ssManagedServer = 1
ssWindowsUpdate = 2
ssOthers = 3

'InStr values
intSearchStartChar = 1


dim strTitle


Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateupdateSearcher()

updateSearcher.ServerSelection = ssWindowsUpdate
Set searchResult = updateSearcher.Search("IsInstalled=0 and Type='Software'")


For I = 0 To searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
strTitle = update.Title
if InStr(intSearchStartChar, strTitle, "KB971033", vbTextCompare) <> "0" then
update.IsHidden = True
end if
Next

WScript.Quit

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...