Thanks for reaching out!
It sounds like you're trying to create a PowerShell script to monitor Active Directory (AD) group membership changes and email a report, here are a few things to keep in mind and suggestions for validating it:
- Test Execution: You can validate your script by performing the following steps:
- Run the script for the first time to ensure it captures the current state of the group.
- Inspect the resulting CSV files to confirm that they are formatted correctly.
- Simulate changes by manually modifying the
SG_App_Access_Members_Last.csvfile to see if the script detects them.- Have an AD admin add and then remove a test account to the group to verify that the script can track real membership changes.
- Multiple Groups: If you plan on monitoring more than one group in the future, consider adding functionality to handle multiple groups efficiently.
- Error Handling: Ensure that your script includes robust error handling, as you’ve started to implement. It’s crucial for troubleshooting issues that may arise during execution.
- Simulate changes by manually modifying the
- Inspect the resulting CSV files to confirm that they are formatted correctly.
- Run the script for the first time to ensure it captures the current state of the group.
Here’s a basic reference for your documentation needs:
- Change Tracking and Monitoring: Monitoring Active Directory for Signs of Compromise
- Active Directory Group Changes: Tracking Changes
- Exporting Data & Sending Emails in PowerShell: Send-MailMessage Documentation
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/send-mailmessage?view=powershell-7.5
Let me know if you need any further help with this. I will be happy to assist.
If you find this helpful, Kindly mark the provided solution as "Accept Answer", so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.