Closed jay7981 closed 1 year ago
What about any errors or things like that? Any warnings, any output?
Here is the output from the RunMe-TriggerOnEvents.ps1
[2022-10-13 14:13:35] [i] Executed Trigger for ID: 5136 and RecordID: 7488468
[2022-10-13 14:13:35] [i] Using Microsoft Teams: True
[2022-10-13 14:13:35] [i] TeamsID: WebhookURL...
[2022-10-13 14:13:35] [i] Using Slack: False
[2022-10-13 14:13:35] [i] Using MSSQL: True
VERBOSE: Get-Events - Preparing data to scan computer Server1
VERBOSE: Get-Events - Filter parameters provided LogName = ForwardedEvents
VERBOSE: Get-Events - Filter parameters provided RecordID = 7488468
VERBOSE: Get-Events - Events to process in Total (unique): 1
VERBOSE: Get-Events - Events to process in Total ID: 5136
VERBOSE: Get-Events - Running query with parallel enabled...
VERBOSE: Get-Events -------------START---------------------
VERBOSE: Get-Events - Inside Server1 for Events ID: 5136
VERBOSE: Get-Events - Inside Server1 for Events LogName: ForwardedEvents
VERBOSE: Get-Events - Inside Server1 for Events RecordID: 7488468
VERBOSE: Get-Events - Inside Server1 for Events Oldest: False
VERBOSE: Get-Events - Inside Server1 - Custom FilterXML:
<QueryList>
<Query Id="0" Path="ForwardedEvents">
<Select Path="ForwardedEvents">
(*[System[EventID=5136]]) and (*[System[EventRecordID=7488468]])
</Select>
</Query>
</QueryList>
VERBOSE: Get-Events - Inside Server1 No events found.
VERBOSE: Get-Events - Inside Server1 Time to generate 0 hours, 0 minutes, 0 seconds, 245 milliseconds
VERBOSE: Get-Events --------------END----------------------
VERBOSE: Get-Events - Overall errors: 0
VERBOSE: Get-Events - Overall events processed in total for the report: 0
VERBOSE: Get-Events - Overall time to generate 0 hours, 0 minutes, 0 seconds, 615 milliseconds
VERBOSE: Get-Events - Overall events processing end
[2022-10-13 14:13:36] [i] Running User Changes Report.
[2022-10-13 14:13:36] [i] Ending User Changes Report.
[2022-10-13 14:13:36] [i] Running User Statues Report.
[2022-10-13 14:13:36] [i] Ending User Statues Report.
[2022-10-13 14:13:36] [i] Running User Lockouts Report.
[2022-10-13 14:13:36] [i] Ending User Lockouts Report.
[2022-10-13 14:13:36] [i] Running Computer Created / Changed Report.
[2022-10-13 14:13:36] [i] Ending Computer Created / Changed Report.
[2022-10-13 14:13:36] [i] Running Computer Deleted Report.
[2022-10-13 14:13:36] [i] Ending Computer Deleted Report.
[2022-10-13 14:13:36] [i] Running Group Membership Changes Report
[2022-10-13 14:13:36] [i] Ending Group Membership Changes Report.
[2022-10-13 14:13:36] [i] Running Group Create/Delete Report.
[2022-10-13 14:13:36] [i] Ending Group Create/Delete Report.
[2022-10-13 14:13:36] [i] Running Group Policy Changes Report.
[2022-10-13 14:13:36] [i] Ending Group Policy Changes Report.
[2022-10-13 14:13:36] [i] Running Who Cleared Logs Report.
[2022-10-13 14:13:36] [i] Ending Who Cleared Logs Report.
[2022-10-13 14:13:36] [i] Running Who Cleared Logs Report.
[2022-10-13 14:13:36] [i] Ending Who Cleared Logs Report.
No errors or warnings at all.
As you can see i have the Event Forwarding working https://prnt.sc/-T3zQ_QGOmCT https://prnt.sc/XYG_0qEYwvXa https://prnt.sc/Vd2_MoiYrg5h
Can you try on something else than a GPO. GPO changes is pretty special, so maybe the conditions are not met when parsing GPO event. And I assume the WebhookURL is placeholder and normally there's like https://... right?
do you mean try setting it up on a server that is not a domain controller? GPO = Group Policy Object ... and i am not using GPO for this in any way .... and yes the webhook is just a placeholder as to not compromise my system/company. Yes its a web url like https://... it was copied and pasted from teams connectors page https://prnt.sc/CBvZqiD3TH-r
no, i mean you are testing this with event ID 5136 which is a group policy object change. Try different ID, something with add computer, delete computer etc
Hrmms, looking at the logs...
<QueryList>
<Query Id="0" Path="ForwardedEvents">
<Select Path="ForwardedEvents">
(*[System[EventID=5136]]) and (*[System[EventRecordID=7488468]])
</Select>
</Query>
</QueryList>
Matches exactly this:
param(
$eventid = 5136,
$eventRecordID = 7488468, # 425358 ,
$eventChannel,
$eventSeverity
)
So it means that you are testing this manually with "wrong id". FInd an even in your forwarded logs that exists, enter it into this params, once you execute this manually - it should work. If it works, then you need to set it up properly.
sorry for the late response, its been crazy at work so i have been real busy. Can i just omit the param section all together and have it report ALL AD events?
Over all my goal is to have it email a daily report for the AD changes that happened the day before and have teams post all changes live as they are made. What is the best way/script to accomplish this?
The way it works is that param section is critical, because you are not supposed to trigger it manually.
The process is described here: https://evotec.xyz/pswinreporting-forwarders-microsoft-teams-slack-microsoft-sql-and-more/
In short:
Now what you need to do is setup Task scheduler that will be assigned to that ForwardedEvents log. What will happen is that for every single event that shows up in that log - it will trigger a script with relevant event id and eventrecordid
Import-Module PSWinReporting -Force
Import-Module PSSharedGoods -Force
$TaskName = 'ForwardedEvents'
$TaskPath = '\Event Viewer Tasks\'
$Author = 'EVOTEC'
$URI = '\Event Viewer Tasks\ForwardedEvents'
$Command = 'powershell.exe'
$Argument = @('-windowstyle hidden', 'C:\Support\GitHub\PSWinReporting\Examples\RunMe-TriggerOnEvents.ps1', '-EventID $(eventID) -eventRecordID $(eventRecordID) -eventChannel $(eventChannel) -eventSeverity $(eventSeverity)')
Remove-TaskScheduledForwarder -TaskPath $TaskPath -TaskName $TaskName
Add-TaskScheduledForwarder -TaskPath $TaskPath -TaskName $TaskName -Author $Author -URI $Uri -Command $Command -Argument $Argument
In other words your DCS will be sending all events to a central place, and for every event they send the script will trigger with specific id, specific event. The param values will be overwritten and the block is required.
I cannot seem to get this to send data to teams even though i have Teams set to true and entered a valid webhook url ... I have event forwarding setup and working, below is the TriggerOnEvents script that i am attempting to use.