changjia
asked on
VBscript to strip off columns in a text file
Hi Experts:
Could someone help me create a vbscript that can strip off "Event" "Source" "Description" columns off the text file I attached and put the rest into a new text file?
Thanks
Could someone help me create a vbscript that can strip off "Event" "Source" "Description" columns off the text file I attached and put the rest into a new text file?
Thanks
Where's the file?
ASKER
sorry, wrong file. Here it is again.
test3.txt
test3.txt
Here's the situation...it looks like you're using a script to dump the data. Whatever method is dumping it in seemingly neat columns, but they're delimeted by spaces and tabs, so there's no easy way to sort through this data.
What about a script to simply read the event log and output only the fields you want? Would that work?
What about a script to simply read the event log and output only the fields you want? Would that work?
ASKER
yes. That would work. I used eventquery.vbs located in c:\windows\system32 to generate the report. I just can't seem to find any script that can do similar things...
ASKER
Actually, I know a way of out putting the file without the Descrition column. Is there a way to add a column called Category into the text file? The output needs to be like this
Type Event Date Time ComputerName Category User
audit failure 537 11/17/2008 10:40:27 PM C2826 Logon/Logoff NT AUTHORITY\SYSTEM
Is this possible to do?
Thanks
Type Event Date Time ComputerName Category User
audit failure 537 11/17/2008 10:40:27 PM C2826 Logon/Logoff NT AUTHORITY\SYSTEM
Is this possible to do?
Thanks
Okay, I ran that script using the following parameters:
cscript %systemroot%\system32\even tquery.vbs /fo /csv /v /l security > c:\security.log
Then this script should grab just the columns you need...
cscript %systemroot%\system32\even
Then this script should grab just the columns you need...
LogFile = "C:\security.log"
NewLog = "C:\newlog.txt"
ColumnsToRecord = Array(0,1,2,4,5,6)
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objFile : Set objFile = objFSO.OpenTextFile(LogFile)
Dim objOut : Set objOut = objFSO.CreateTextFile(NewLog)
'Skip header data
For x = 0 to 4
objFile.ReadLine
Next
strHost = objFile.ReadLine
objOut.WriteLine "Results for:" & Replace(mid(strHost, Instr(strHost, "host")+4),chr(39),"")
objOut.WriteLine
For x = 0 to 2
objFile.ReadLine
Next
Do While Not objFile.AtEndOfStream
strRead = objFile.ReadLine
If Trim(strRead) <> "" Then
arrData = Split(strRead, ",")
For Each item in ColumnsToRecord
strData = strData & vbTab & arrData(item)
Next
objOut.WriteLine Mid(strData,2)
strData=""
End If
Loop
objOut.Close
objFile.Close
ASKER
Sirbounty:
T
he newlog.ext only shows me a result like this:
Please view the attached text file.
What is the top line of text? Is there a way to remove them?
Thanks
newlog.txt
T
he newlog.ext only shows me a result like this:
Please view the attached text file.
What is the top line of text? Is there a way to remove them?
Thanks
newlog.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the help!
I actually had to use Perl to do this. It is much easier than using VBscript.
But thank you very much for the help!
I actually had to use Perl to do this. It is much easier than using VBscript.
But thank you very much for the help!