UPDATE: The most recent update is available on Github

I found some time to update the script “Monitor Active Directory Membership changes”. This is the version 1.6.

To summarize, this script allow you to monitor Active Directory groups membership changes. The script will send your a report via email only when a change occur. I explained in details in my last post how the script work.

So what are the main changes in this version ?

SearchRoot you can now specify the Organization Unit path(s) where all your groups are located, the script will take care of the rest and watch them all. You also have the option to filter using the parameters SearchScope , GroupType , GroupScope .

File you can now specify one or multiple files where the list of groups is saved. Distinguished Names, SID, GUID, GroupName, Domain\GroupName are accepted.

Previous post related to this script: [2013/10] PowerShell - Monitor and Report Active Directory Group Membership Change [2012/03] Powershell - Monitor Active Directory Groups membership change

Thank you: I want to thank those who sent me suggestions via email or posts comments, I’m very happy to see that this script is helping a lot of my fellow sysadmins.

Overview

Version 1.6 Changes

Requirements

Report Example

Using the Script

Running the script the first time

Running the script a second time

Running the script after a change

Using the SearchRoot parameter (Organizational Unit path)

Using the File parameter

Syntax

Help

Download

Version 1.6 Changes

Support for Organization Unit path(s)

SearchRoot parameter You can know specify a DN or a CanonicalName where all the groups you want to monitor are located.

SearchScope parameter

Base : Limits the search to the base (SearchRoot) object.The result contains a maximum of one object.

OneLevel : Searches the immediate child objects of the base (SearchRoot) object, excluding the base object.

Subtree : Searches the whole sub-tree, including the base (SearchRoot) object and all its child objects.

GroupScope parameter Specify the group scope of groups you want to find. Acceptable values are :

Global

Universal

DomainLocal

GroupType parameter Specify the group type of groups you want to find. Acceptable values are:

Security

Distribution

Support for File(s)

Input Specify the File where the Group are listed. DN, SID, GUID, or Domain\Name of the group are accepted

Update of the ParameterSetNames

Group

Organization Unit

List

Change History files

In the previous version, a file was generate for each change of each group, I decided to use only one file per group for the change history. The script will just append the new information to it.

Membership and Changes History files changes

ADD Properties DisplayName and the DateTime

Report changes

ADD Additional information on the Group

ADD Title include the DOMAIN\GroupName

[MailAddress] type which is available in PowerShell v3.0 has been removed on the parameter $Emailto and $EmailFrom to allow support on PowerShell 2.0. This is actually replaced by a Regular Expression validation

… and some more minors other changes…

Note: Unfortunately, if you were already using the script, this update won’t work with the old ChangeHistory.csv files (So you will need to archives the old ones in another directory). I added some properties and decided to keep only one file per group to track the change history, these changes are not compatible with the old files (previous to version 1.6)

Requirements

PowerShell v3.0

PowerShell Snapin from Quest : ActiveRoles Management Shell for Active Directory

A Scheduled Task to run every X minutes

Permission to Read Group(s) Membership in AD

Permission to write CSV files locally

EmailTo and EmailFrom must have an Email Format (Regex validation). [email protected] won’t work

Report Example

Here is a quick example of report generated by the script.

Changes:



Email Subject contains the DOMAIN\GROUPNAME

Add some Information about the group

Columns in Membership Change and Change History now matche

New Columns DisplayName and DateTime

Using the script

In the following example I’m playing with two test groups: FXGROUP01 and FXGROUP02 For my test, I placed the script in the directory C:\LazyWinAdmin\Tool-Monitor-AD_Groups

Running the script the first time

You will notice that the script is creating folders and files. At this point you won’t get any email report.

VERBOSE: Creating the Output Folder : C:\LazyWinAdmin\TOOL-MONITOR-AD_Group\Output VERBOSE: Creating the ChangeHistory Folder : C:\LazyWinAdmin\TOOL-MONITOR-AD_Group\ChangeHistory VERBOSE: GROUP: FXGroup01 VERBOSE: FXGroup01 - The following file did not exist: FX_FXGROUP01-membership.csv VERBOSE: FXGroup01 - Exporting the current membership information into the file: FX_FXGROUP01-membership.csv VERBOSE: FXGroup01 - Comparing Current and Before VERBOSE: FXGroup01 - Compare Block Done ! VERBOSE: FXGroup01 - No Change VERBOSE: GROUP: FXGroup02 VERBOSE: FXGroup02 - The following file did not exist: FX_FXGROUP02-membership.csv VERBOSE: FXGroup02 - Exporting the current membership information into the file: FX_FXGROUP02-membership.csv VERBOSE: FXGroup02 - Comparing Current and Before VERBOSE: FXGroup02 - Compare Block Done ! VERBOSE: FXGroup02 - No Change VERBOSE: Script Completed

Two directories and two files are created:

2 Files For each of the groupwe just queried FXGROUP01 and FXGROUP02 . Since these groups are currently empty, the script will add the value “No User or Group” in both files.

OUTPUT Directory Each time the script run, It query the group membership in the Active Directory and save the current membership in the files (It won’t touch the file if it’s the same membership at each check).

CHANGEHISTORY Directory contains the list of changes observed by the script. One file per Group per domain, if multiple changes occur, the script will append the change in the same file.

Output Directorycontains the 2 files for each monitored groups