PowerShell Script to Get Active Directory Builtin Groups Members

Built-in groups are predefined security groups, defined with domain local scope, that are created automatically when you create an Active Directory domain. It is important to check the members of these groups time to time. And here is a simple script for that purpose. This PowerShell script gets the members of Active Directory Builtin Group Members and export the result to csv file.

Jan 19, 2023 - 16:03
Feb 20, 2023 - 13:57
PowerShell Script to Get Active Directory Builtin  Groups Members
PowerShell Script - Get Builtin Group Members

You can use builtin groups to control access to shared resources and delegate specific domain-wide administrative roles.

This PowerShell script gets the members of Active Directory Builtin Group Members and export the result to  csv file.

NOTE: This script will only work if the computer running the script is connected to an Active Directory Domain, and the user running it has the permissions to read the group membership. Also, the path of the exported file should exist, otherwise the export will fail.

Quick link to script:

powershell/get_builtingroupmembers.ps1 at main · kbsuperuser/powershell (github.com)

*******

<#
.SYNOPSIS
   Get Active Directory Builtin Group Members
.DESCRIPTION
    This PowerShell script gets the members of Active Directory Builtin Group Members and export the result to  csv file.
.EXAMPLE
    PS> ./get_builtingroupmembers

.LINK
    https://github.com/kbsuperuser/powershell
.NOTES
    Author: kbsuperuser.com | License: CC0
#>

Import-Module ActiveDirectory

$builtinGroups = @("Administrators", "Backup Operators", "Guests", "Users", "Power Users", "Account Operators", "Server Operators", "Print Operators", "Backup Operators", "Replicator")
$Results = @()

foreach ($group in $builtinGroups) {
    $members = Get-ADGroupMember -Identity $group -Recursive | Select-Object Name, SamAccountName
    foreach ($member in $members) {
       $Results += New-Object PSObject -Property @{
        Group = $group
        Name = $member.Name
        SamAccountName = $member.SamAccountName
       }
    }
}
$Results | Export-Csv -Path "C:\temp\AD_builtin_groups_members.csv" -NoTypeInformation

*******

What's Your Reaction?

like

dislike

love

funny

angry

sad

wow