Pull Account Name from Message in Eventlog - powershell

11,829

Take a look at the second item of the ReplacementStrings property of each event. It contains the values embeded in the message.

get-eventlog -computername dc-01 -logname security | ?{$_.eventid -eq "4674"} | 
select machinename,eventid,@{n='AccountName';e={$_.ReplacementStrings[1]}},entrytype,message | 
convertto-html | out-file c:\test.html
Share:
11,829
JMeterX
Author by

JMeterX

User, n. The word computer professionals use when they mean "idiot." -Dave Barry

Updated on June 28, 2022

Comments

  • JMeterX
    JMeterX almost 2 years

    I want to pull the account name from the message property in an event log. For instance I am running the following command:

    get-eventlog -computername dc-01 -logname security | ?{$_.eventid -eq "4674"} | convertto-html -property machinename,eventid,entrytype,message | out-file c:\test.html
    

    I want to be able to pull the account name out of message but not necessary for specific users. Ideally, it would create another column named Account Name which we could sort on