Skip to content

IT-Admins

a website from a systems administrator for systems administrators

    • Home
    • IT-Admins CMDB
      • ITAM – Features
      • ITAM – Release Notes
      • ITAM – Download
      • ITAM – Installation
      • ITAM – Online Manual
        • ITAM – General Functions
        • ITAM – Settings
        • ITAM – Common Modules
          • ITAM – Main Page
          • ITAM – Workstations
          • ITAM – Monitors
          • ITAM – Printers
          • ITAM – Toner-Inventory
          • ITAM – Servers
          • ITAM – Infrastructure Assets
          • ITAM – Other Assets
          • ITAM – Purchases
          • ITAM – Employees
          • ITAM – Software
          • ITAM – Projects and Project Tasks
          • ITAM – Phones/DIDs
          • ITAM – IP Addresses
          • ITAM – Responsibility Matrix
          • ITAM – IT Supplies
        • ITAM – Less Common Modules
          • ITAM – Departments
          • ITAM – Vendors
          • ITAM – Expenses
          • ITAM – Checklist Templates
          • ITAM – LDAP Groups
          • ITAM – Phones and Phone Models
          • ITAM – Links
          • ITAM – Reminders
          • ITAM – Printer Models and Supplies
          • ITAM – VLANs
          • ITAM – Databases
          • ITAM – WebServer
          • ITAM – Certificates
          • ITAM – DNS Entries and Zones
        • ITAM – Research Modules
          • ITAM – TAGs
          • ITAM – Notes
          • ITAM – Checklists
          • ITAM – Incidents
          • ITAM – MAC address search
          • ITAM – LDAP sync Log
          • ITAM – WMI Log
          • ITAM – LDAP compare
          • ITAM – Service Log
    • IT-Admins tool
      • IT-Admins Tool – Features
      • IT-Admins Tool – Scenarios
      • IT-Admins Tool – Screenshots
      • IT-Admins Tool – Release notes
      • FAQ
      • IT-Admins Tool – Download
      • IT-Admins Tool – Online Manual
        • IT-Admins Tool – Overview
        • IT-Admins Tool – Generic search functions
        • IT-Admins Tool – Configuration
        • IT-Admins Tool – Domain Users
        • IT-Admins Tool – Domain Groups
        • IT-Admins Tool – Domain Computers
        • IT-Admins Tool – Domain Contacts
        • IT-Admins Tool – NTFS ACLs
        • IT-Admins Tool – Long Paths
        • IT-Admins Tool – Directory compare
        • IT-Admins Tool – Search function
    • IT Search
      • IT Search – How it works
      • IT Search – Release Notes
      • IT Search – Download
      • IT Search – Installation
      • IT Search – Online Manual
        • Applying updates
        • Search Providers
        • Configuration
        • Error Log viewer
        • Active Users
        • Monitoring and Statistics
        • Backup and Restore
    • EOL Solutions
      • IT Printer Management (EOL)
        • Printer Management EOL – Installation
        • Printer Management EOL – Download
        • Printer Management EOL – Online Manual
          • Printer Management EOL – Executing the script
          • Printer Management EOL – Using the Sys-Search
          • Printer Management EOL – Managing printers
          • Printer Management EOL – Reviewing the log
          • Printer Management EOL – User to printer (v2)
          • Printer Management EOL – Computer to printer (v2)
      • IT Assets Database (EOL)
        • IT Assets DB Video
        • EOL Asset DB – Features
        • EOL Asset DB – Installation
        • EOL Asset DB – Release Notes
        • EOL Asset DB – Update to the newest version
        • EOL Asset DB – Download
        • EOL Asset DB – Online manual
          • EOL Asset DB – Overview
            • EOL Asset DB – The floating / roaming task execution
          • EOL Asset DB – Using the the sys search
          • EOL Asset DB – Main menu
          • EOL Asset DB – Workstations
          • EOL Asset DB – Monitors
          • EOL Asset DB – Departments
          • EOL Asset DB – Printers
            • EOL Asset DB – Printer models and supplies
            • EOL Asset DB – Toner inventory
          • EOL Asset DB – Incidents
          • EOL Asset DB – Software and licenses
          • EOL Asset DB – LDAP change reporting / synchronization
            • EOL Asset DB – Employees
            • EOL Asset DB – LDAP Groups
          • IP addresses – IPAM
          • EOL Asset DB – DNS management
          • EOL Asset DB – Servers and equipment
            • EOL Asset DB – databases
            • EOL Asset DB – backup reviews
            • EOL Asset DB – Certificate management
            • EOL Asset DB – Webserver Management
          • EOL Asset DB – Vendors and contacts
          • EOL Asset DB – Links and URLs
          • EOL Asset DB – Reminders
          • EOL Asset DB – Purchases
          • EOL Asset DB – Expenses
    • Current Page Parent Blog
    • Contact
    • Links

    Monitor group memberships in Active Directory with PRTG

    There is at least one group you want to monitor for any membership changes in Active Directory / LDAP – the Domain Admins group. This is so important, as any changes to this group could cause great harm to your whole system. Of course there are other ways in but you for sure want to monitor at least the basic information of the amount of users in this group.

    In order to do so, I wrote a PowerShell script that provides you the amount of members of any given group in Active Directory, as well as a text response (under the probe name and in some alerts if activated) of the sAMAccountName of each member in the group. This way you can hopefully right away determine the changed object, assuming you know what should be in there and what not.

    If you have nested groups, you might wanna monitor them as well till you reach a user only level.

    Create the script as always on your PRTG probing server in C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML and add a new EXE/Advanced XML sensor in PRTG. Select the script and provide at a bare minimum the parameter MonitoredGroup.

    Parameter samples:

    • -MonitoredGroup “Domain Admins”
    • -MonitoredGroup “Domain Admins” -Server “MyDC.domain.local”

    If you do not provide a server name, the system will try determine it on it’s own – default Domain-Membership etc..

    Once the first run was successful you should review the results and set the upper and lower error limit on the PRTG sensor to the current amount of members. Any change then will cause the sensor to go in to error status and inform you therefor about the change.

    Get-LDAPGroupChanges.ps1
    PowerShell
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    param(
    [string]$Server = "",
    [string]$MonitoredGroup = ""
    )
    Import-Module ActiveDirectory
     
    If ($Server.Length -gt 0) {
        $LDAPGroup = Get-ADGroupMember $MonitoredGroup -Server $Server
    } Else {
        $LDAPGroup = Get-ADGroupMember $MonitoredGroup
    }
     
    [string]$LDAPGroupMembers = ""
    Foreach ($Member in $LDAPGroup){
        If ($LDAPGroupMembers.Length -gt 0) {$LDAPGroupMembers += ", "}
        $LDAPGroupMembers += $Member.SamAccountName
    }
     
    $XML = "<prtg>
                <result>
                    <channel>Amound of Users in Group</channel>
                    <value>"+ $LDAPGroup.count +"</value>
                </result>
                <text>"+ $MonitoredGroup +" Members: " + $LDAPGroupMembers + "</text>
            </prtg>"
    Function WriteXmlToScreen ([xml]$XML) #just to make it clean XML code...
    {
    $StringWriter = New-Object System.IO.StringWriter;
    $XmlWriter = New-Object System.Xml.XmlTextWriter $StringWriter;
    $XmlWriter.Formatting = "indented";
    $xml.WriteTo($XmlWriter);
    $XmlWriter.Flush();
    $StringWriter.Flush();
    Write-Output $StringWriter.ToString();
    }
    WriteXmlToScreen $XML;

     

    Tags: accountactive directoryldapmonitoringnotificationpowershellprtgscriptsecurity

    October 13, 2020 by Florian Rossmark monitoring prtg scripts security server

    You may also like...

    • Script to remove RemoteApp and Desktop Connections

      Script to remove RemoteApp and Desktop Connections

    • Excel custom views and Excel files that appear different for various users

      Excel custom views and Excel files that appear different for various users

    • Monitor multiple file sizes in one PRTG sensor

      Monitor multiple file sizes in one PRTG sensor

    • Next Make Microsoft TEAMS the default IM application
    • Previous Auditing network users against HR lists etc.

    Recent blog posts

    • PRTG sensor to monitor a directory for a specific file type and minimum size and age February 15, 2023
    • APC NetBotz 250 SNMP monitoring with PRTG December 6, 2022
    • Linux and DHCP reservations aren’t working June 28, 2022
    • Check your webpage for mobile friendly readiness June 15, 2022
    • Tools for WebAnalytics and SEO April 21, 2022

    Blog Archives

    Tags

    dhcp Office 365 eventlog windows powershell account veritas filesystem slack dfs cleanup server javascript office backup exec UEFI rds SNMP notification network password website outlook lockout certificate database sql active directory ip ssl ldap profile gpo excel html print backup script web vmware security performance automate prtg monitoring
    • Terms & Conditions
    • Privacy Policy
    • Opt-out preferences
    • SPICEWORKS
    • LOPSA
    • RSS
    • LinkedIn
    • ITML
    • XING

    IT-Admins © 2025. All Rights Reserved.

    Powered by WordPress. Theme by Alx.

      Manage Cookie Consent
      To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
      Functional Always active
      The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
      Preferences
      The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
      Statistics
      The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
      Marketing
      The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
      Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
      View preferences
      {title} {title} {title}