Roberto Alves

Scripting and server based computing

.VBS to compare applications version on all servers

This is a very, very and very simple inventory tool. But can be very useful on sbc environments. This script checks the list of applications on Add/Remove Programs of each server, and writes a result in a table inside a html file.  Then, you can compare if all servers has same software installed or same updates!

To have a reliable Citrix or Terminal Services environment, you need ensure that all servers on each silo are equal, to all users get same applications, updates, etc.

You need save on the same directory of this script, a file called servers.txt with the list of servers that you wish verify. Must to be a server per line and script will read one by one, from the of the file. After run, I prefer open the html file on Excel and treat data, sorting by application name and lighting issues with different colours.

For each application found on each server, the script writes a “x” on the respective column of that server.

Option Explicit

Dim StrComputer
Dim fso, ServersFile, result,stotal(300,14), x,y,z

Set fso = CreateObject(“Scripting.FileSystemObject”)
Set ServersFile = fso.OpenTextFile(“servers.txt”, 1, True)
Set result = fso.OpenTextFile(“Result.htm”, 2, True)

result.writeline “<table align=center colspan=30 valign=top><tr>”

y = 1

Do Until ServersFile.AtEndOfStream
strComputer = serversfile.readline
Dim s : s = GetAddRemove(strComputer)
y = y + 1
Loop

result.writeline “<td valign=top>”
result.writeline “<table border=1 cellspacing=0 cellpadding=0 valign=top width=600>”
result.write “<tr><b><td>ServerName</td><td>01</td><td>02</td><td>03</td><td>04</td><td>05</td><td>06</td><td>07</td><td>08</td><td>09</td><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td></b></tr>”

for x=0 to 300
if trim(stotal(x,0))<>”" then
result.writeline “<tr>”
for z = 0 to 14
result.write “<td>” & stotal(x,z) & “</td>”
next
result.writeline “</tr>”
end if
next
result.writeline “</tr></table>”
result.writeline “</td>”

result.writeline “</tr></table>”

msgbox “Done!”

Function GetAddRemove(sComp)

Dim cnt, oReg, sBaseKey, iRC, aSubKeys
Dim sKey, sValue, sTmp, sVersion, sDateValue, sYr, sMth, sDay

Const HKLM = &H80000002 ‘HKEY_LOCAL_MACHINE

Set oReg = GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & sComp & “/root/default:StdRegProv”)
sBaseKey = “SOFTWAREMicrosoftWindowsCurrentVersionUninstall”
iRC = oReg.EnumKey(HKLM, sBaseKey, aSubKeys)
For Each sKey In aSubKeys
iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey, “DisplayName”, sValue)
If iRC <> 0 Then
oReg.GetStringValue HKLM, sBaseKey & sKey, “QuietDisplayName”, sValue
End If
If sValue <> “” Then
iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey,”DisplayVersion”, sVersion)
If sVersion <> “” Then
sValue = sValue & vbTab & “Ver: ” & sVersion
Else
sValue = sValue & vbTab
End If
iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey,”InstallDate”, sDateValue)
x=0
do while x <= 300
if trim(sTotal(x,0)) = trim(svalue) then
stotal(x,y) = “x”
x=301
elseif trim(sTotal(x,0)) = “” then
stotal(x,0) = trim(svalue)
stotal(x,y) = “x”
x=301
end if
x= x + 1
loop
cnt = cnt + 1
End If
Next
End Function

Function GetProbedID(sComp)
Dim objWMIService, colItems, objItem
Set objWMIService = GetObject(“winmgmts:\” & sComp & “rootcimv2″)
Set colItems = objWMIService.ExecQuery(“Select SystemName from Win32_NetworkAdapter”,,48)
For Each objItem in colItems
GetProbedID = objItem.SystemName
Next
End Function

Category: Citrix, Scripts

Your email address will not be published. Required fields are marked *

*