Need a VB Script
I would usually create something like this in Powershell, but the majority of the machines this will be ran on will be XP. I'm not too familiar with VB scripting since for whatever reason I skipped over it, and went straight to Powershell.
I need something that will look at a log file in a specific path. Is there a way to look in both paths in one script?
Win 7 - %PROGRAMDATA%\Sophos\AutoUpdate\Logs\alc.log
Win XP- %PROGRAMFILES%\Sophos\AuotUpdate\Logs\alc.log
I would usually run a ShellCommandTextReturn custom inventory in Kace, but this is a pretty lengthy log file. I'm looking for a particular string "Download of Sophos AutoUpdate Failed from Server http://<servername>/CIDs/<old_path>/SAVSCFXP/". This should get if any of my machines are pointing to the wrong update path.
I then need to take that entry if it exists, and export to a txt file so that I can have Kace inventory it. I can then add it to my report.
I've got this so far. I would like one script to run on both XP and Win 7. I'm running this using "cscript script.vbs //NoLogo > c:\temp.txt". This gives me an output as text file.
Const ForReading = 1 strFileName = "C:\ProgramData\Sophos\AutoUpdate\Logs\alc.log" strFailed = "Download of Sophos AutoUpdate Failed from Server" strSucceeded = "SophosAutoUpdate" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(strFileName, ForReading) strText = objFile.ReadAll objFile.Close IF InStr(strText, strFailed) Then WScript.Echo "Download of Sophos AutoUpdate failed from server http://<servername>/CIDs/S009/SAVSCFXP/" ELSEIF InStr(strText, strSucceeded) Then WScript.Echo "Update Successful" End IF