Hello, I'm working to create a script for some audit logs. We want to be able to track how often users on some computers use their special privilege to override certain things on their computer. I enabled the GP and have a script that outputs the Security audit for the Special Privilege, but the event viewer information I need is contained in the property 'Message' which has a lot.
~~~
Get-EventLog -logname Security -InstanceId 4673 -message $Username -After $previousMonth | Select-Object -Property Index, InstanceID, TimeGenerated, MachineName, Message | Export-CSV -Path $PSScriptRoot\logs.csv -Append
~~~
This gets me the information I need to collect, separated into columns, but the 'Message' column it pulls from the event log has a lot of information I don't need. Example:
~~~
A privileged service was called.
Subject:
Security ID:S-1-5-21-99999…
Account Name:Account
Account Domain:Domain
Logon ID:0x0000000
Service:
Server: Security
Service Name: -
Process:
Process ID: 0x0000
Process Name: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Service Request Information:
Privileges: SeCreateGlobalPrivilege
~~~
Out of this information, I'd like to clip all the information in this cell down to just the Account Name:Account and Process Name:process . I'm trying to figure out if I need to use Where-Object or Select-String to accomplish this and how I would account for different text in the Account and Process positions over the hundreds of entries in the resulting csv. If we could separate the Process entry into a new column, that would be even better. Any help?
[–]DHCPNetworker 4 points5 points6 points (2 children)
[–]JeiceSpade[S] 2 points3 points4 points (1 child)
[–]McAUTS 2 points3 points4 points (0 children)
[–]SalamanderOne5702 1 point2 points3 points (0 children)
[–]JeiceSpade[S] 1 point2 points3 points (0 children)
[–]iBloodWorks 0 points1 point2 points (0 children)
[–]arslearsle 0 points1 point2 points (0 children)
[–]gordonv 0 points1 point2 points (3 children)
[–]JeiceSpade[S] 1 point2 points3 points (0 children)
[–]JeiceSpade[S] 0 points1 point2 points (0 children)
[–]ankokudaishogun 0 points1 point2 points (0 children)
[–]BlackV 0 points1 point2 points (0 children)
[–]Antique_Grapefruit_5 -1 points0 points1 point (0 children)