Avatar of Brian S
Brian S
Flag for United States of America asked on

command line results for dcdiag and eventlogs

I'm preparing a script to parse looking for information from DC Diag and eventlogs on a Windows 2008 R2 server.

My question is this how can I via command line search for events in the eventlogs (e.g. EventIDs) and what is the path to dcdiag? I can see that I can just run it via the command line without a path, but if I want to script it I need a path.

any help would be appreaciated.
Active DirectoryWindows Server 2008VB Script

Avatar of undefined
Last Comment
prashanthd

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
prashanthd

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Brian S

ASKER
Wow that was quick. I'll give that a go.
prashanthd

Missed the date conversion
'On Error Resume Next

servername="."
Set objWMIService = GetObject("winmgmts:\\" & ServerName & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where EventCode=1079")

For Each objEvent In colLoggedEvents      
    WScript.Echo  objEvent.EventCode &","& WMIStringToDate(objEvent.TimeWritten)
Next    

'DCdiag Test
dcdiagout=""
Set objShell = CreateObject("Wscript.Shell")
dcocommand = "dcdiag /s:"& ServerName

Set objExec = objShell.Exec(dcoCommand) 

dcdiagout=objExec.StdOut.ReadAll()

WScript.Echo "dcdiag " & dcdiagout

Function WMIStringToDate(dtmDate)
    WMIStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
    Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
    & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

Open in new window

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes