1

i am trying to objectify the security event log by using the ConvertFrom-String PowerShell cmdlet, but am not able to work it out.

First i am getting the event/s from my DC.

$events = Get-WinEvent -ComputerName $comp FilterHashtable @{logname='security';id=4727}

Next i define my template.

$tmpl = @' {Event:A security-enabled global group was created.} Subject: Security ID: S-1-5* {SubjectName:Account Name: andrew} Account Domain: DOMAIN Logon ID: 0x16D280EB New Group: Security ID: S-1-5* {GroupName:Group Name: test1} Group Domain: DOMAIN Attributes: SAM Account Name: test1 SID History: - Additional Information: Privileges: - '@

Finally i try to turn it into objects.

($events).message | ConvertFrom-String -TemplateContent $tmpl

But my output is only

Event: A security-enabled global group was created.

Instead, I want to get something like;

  • Event: A security-enabled global group was created
  • SubjectName: andrew
  • GroupName: test1

And i would like this to be compatible to loop through many similar events to pull out the right bits??

ajhstn
  • 21
  • 4

1 Answers1

1

I posted the same question in the Microsoft forums and got an immediate answer, and so for those interested, here it is.

https://social.technet.microsoft.com/Forums/windowsserver/en-US/42f8e6a3-4304-4215-b521-d611e3216e1c/eventlog-convertfromstring?forum=winserverpowershell

ajhstn
  • 21
  • 4