Search


Sponsors

SUS Sync Notifier

Tired of checking each morning if the SUS server has updates download and ready to approve? I wrote a VBS script that checks the status and sends an email when there are updates ready to approve. You need W2000 or above to run it and the user account running the scripts needs access to C:\Inetpub \wwwroot \autoupdate \administration \history-sync.xml. Use the script by scheduling it with the MS Task Scheduler.

SUS_SYNC.VBS

Option Explicit

Call main()

Sub main
Dim xml
Set xml = CreateObject("MSXML2.DOMDocument")
xml.Load ("C:\Inetpub\wwwroot\autoupdate\administration\history-sync.xml")
Dim entries
Set entries = xml.selectNodes("/log/entry")
Dim max
max = entries.length

Dim i 'As Integer
Dim entry
Dim item
Dim resultText
Dim items
Dim itemList
Dim msg
'last item
Set entry = entries.item(max - 1)
msg = "last SUS Synchronisation : " & entry.Attributes(1).Text
Set resultText = entry.selectSingleNode(".//resultText")
msg = msg & vbCrLf & "resultText : " & resultText.Text & vbCrLf
Set itemList = entry.selectSingleNode(".//itemList")
If itemList.hasChildNodes = True Then
msg = msg & vbCrLf & "the following items need to be approved : " & vbCrLf
Else
mail msg
Exit Sub
End If
'go thru all news items
Set items = itemList.childNodes
For i = 0 To items.length - 1
Set item = items.item(i)
If item.selectSingleNode(".//itemID").Text <> "" Then
msg = msg & vbCrLf & item.selectSingleNode(".//title").Text
End If
Next
'MsgBox msg
mail msg
End Sub

Sub mail(msg)
Dim objEmail
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "sus@mydomain.com"
objEmail.To = "admin@mydomain.com"
objEmail.Subject = "SUS Sync Notifier"
objEmail.Textbody = msg
objEmail.Configuration.fields.item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.fields.item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"my_mail_server"
objEmail.Configuration.fields.item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.fields.Update
objEmail.send
wscript.echo "mail was sent..."

End Sub



  
Remember personal info?

Emoticons / Textile

Before sending a comment, you have to correctly answer a simple question you know the answer to. This is a countermeasure against automated spam bots.
 

  ( Register your username / Log in )

Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.