r/PowerShell • u/MadBoyEvo • Sep 16 '18
Script Sharing PSWinReporting - Monitoring active directory events and sending it to Email, Microsoft Teams, Slack, SQL
For those who don't know this module it's purpose is simple - monitoring Active Directory for events such as creating new users, adding users to groups, deleting users and so on. If you've ever wondered who added this guy to Domain Admins this tool can tell you.
By default (the old version) it was only able to send it to Email with nice reports. New version adds:
Support for Event Forwarding – monitoring one event log instead of scanning all domain controllers
Support for Microsoft Teams – Sending events as they happen to Microsoft Teams (only supported when forwarders are in use)
Support for Slack – Sending events as they happen to Slack (only supported when forwarders are in use)
Support for Microsoft SQL – Sending events directly to SQL (some people prefer it that way) - including create table, alter table and insert rows with table mapping in place
Support for backing up old archived logs (moves logs from Domain Controllers into chosen place)
Support for re-scanning logs from files – a way to recheck your logs for missing information
The last one is still in progress but should be usable soon.
Blog about new release (how to and so on): https://evotec.xyz/pswinreporting-forwarders-microsoft-teams-slack-microsoft-sql-and-more/
Module page: https://evotec.xyz/hub/scripts/pswinreporting-powershell-module/
Sources are on GitHub, and installable from PowershellGallery (preferred way). It utilizes following modules for different functionalities (available on github/powershellgallery)
PSTeams - https://github.com/EvotecIT/PSTeams # my module
PSSlack - https://github.com/RamblingCookieMonster/PSSlack # module from RamblingCookieMonster
PSWriteExcel - https://github.com/EvotecIT/PSWriteExcel # my module
DBATOOLS - https://github.com/sqlcollaborative/dbatools # module for SQL support by SqlCollaborative
PSSharedGoods - https://github.com/EvotecIT/PSSharedGoods # my module - I'm exporting all my functions that are common for all my modules into this one.




2
Sep 17 '18 edited Sep 17 '18
I used the sample config here to set everything in $ReportTimes to $false except PastDay, but it still tries to show me everything from the past week. Anyone else?
Ninja edit: Never mind, I see the one-day report. It also generates a one-week report, though, and I'm not sure why.
2
u/MadBoyEvo Sep 17 '18
Can you post log output? I will check code as it was last minute change that I did to dates. Maybe I mixed something up.
2
u/MadBoyEvo Sep 17 '18
Just rerun this. Set pasthour to true, pastday to true and it generated me 2 reports.
1st:
[2018-09-17 20:13:08][i] Processing report for dates from: 09/17/2018 19:00:00 to 09/17/2018 20:00:00
2nd:
[2018-09-17 20:15:43][i] Processing report for dates from: 09/16/2018 00:00:00 to 09/17/2018 00:00:00
Seems to be fine.
2
u/MadBoyEvo Sep 17 '18
if you enable multiple reports as in there are multiple true values it will generate multiple reports. you must have somewhere there additional true.
2
Sep 17 '18
This was it. I wasn't paying attention and there was indeed another true in there. Thanks! This module is great!
2
u/Betsy-DeVos Sep 16 '18
Neat tool, I dont have much use for the overall script in my current role but I will definitely be using the teams message support for some reporting that I want to do once our lazy office/sharepoint admins enable the features I asked for 3 months ago.
2
u/halbaradkenafin Sep 16 '18
You might also be interested in PoshBot then, it hooks into Teams now and gives you another option for automating things and getting people away from RDP and similar.
2
u/MadBoyEvo Sep 17 '18
I actually have plans for PoshBot to integrate some of my scripts into it. But it's a bit special to set it up.
4
0
Sep 16 '18
[deleted]
2
u/MadBoyEvo Sep 16 '18
If it doesn't open an issue on GitHub. I'll try to help and fix code if needed. It's supposed to be flexible but I did test it only on couple of systems / environments. Always good to get another angle. What's most interesting for you in this?
2
u/sup3rlativ3 Sep 17 '18
Seems like a great tool. Your blog post doesn't make it clear though, how to get it all working if you want multiple alerting options. For example, I would like slack and email notifications because some people like to know straight away e.g. me while others would just like a summary e.g. my manager.
I've setup event log forwarding and can confirm that is working. I have copied the same code from the blog post and had it create the events etc. The last piece is the script that is called from the scheduled task. I copied the first iteration of the script from the blog post and enabled the slack notifications but then the second iteration is missing the slack portion. I would also like it to report to me directly and as it stands it seems like I need to specify a channel rather than myself?
I'm not sure if I'm just being dense or if this is more complicated than it should be. Is there a function to enable certain notifications? Some clarity would be nice to get everything working.