Function SNMPGET(vServer, vCommunityString, vOID) On Error Resume Next 'This function will return the data from an SNMP get from the specified 'server and the specified OID. The information will have to be parsed 'afterward. The info will be retuned as the string or variable "SNMPGET". 'This script is provided under the Creative Commons liscense located 'at http://creativecommons.org/licenses/by-nc/2.5/ . It may not 'be used for comercial purposes with out the expressed written consent 'of NateRice.com Const OpenAsDefault = -2 Const FailIfNotExist = 0 Const ForReading = 1 vSNMPGetPath = "C:\ScriptFiles" 'Set path to snmpget.exe Set WshShell = CreateObject("WScript.Shell") 'Create filesystem objects sTemp = WshShell.ExpandEnvironmentStrings("%TEMP%") sTempFile = sTemp & "\runresult.tmp" 'Create working file string 'Run the SNMPGET command and save results to tmp file WshShell.Run "%comspec% /C " & vSNMPGetPath & "\snmpget -c " & _ vCommunityString & " -v 1 " & vServer & " " & vOID & " > " & _ sTempFile, 0, True 'Read tmp file for snmpget results Set oFSO = CreateObject("Scripting.FileSystemObject") Set fFile = oFSO.OpenTextFile(sTempFile, ForReading, FailIfNotExist, _ OpenAsDefault) SNMPGET = fFile.Readline If InStr(SNMPGET, "STRING:") > 0 Then aSNMPGET = Split(SNMPGET, "STRING:") vTemp = Replace(Trim(aSNMPGET(1)), Chr(34), "") SNMPGET = vTemp ElseIf InStr(SNMPGET, "INTEGER:") > 0 Then aSNMPGET = Split(SNMPGET, "INTEGER:") vTemp = Trim(aSNMPGET(1)) vTemp = vTemp + 0 SNMPGET = vTemp ElseIf InStr(SNMPGET, "IpAddress:") > 0 Then aSNMPGET = Split(SNMPGET, "IpAddress:") vTemp = Trim(aSNMPGET(1)) SNMPGET = vTemp End If fFile.Close oFSO.DeleteFile (sTempFile) End Function