Skip to content

Instantly share code, notes, and snippets.

@joshfinley
Created January 25, 2024 18:16
Show Gist options
  • Save joshfinley/d11cc0db8f2552c20456322202b9926b to your computer and use it in GitHub Desktop.
Save joshfinley/d11cc0db8f2552c20456322202b9926b to your computer and use it in GitHub Desktop.
# Import the Active Directory module
Import-Module ActiveDirectory
# Group name to search for
$groupName = "YourGroupName"
# Get the group
$group = Get-ADGroup -Filter { Name -eq $groupName }
if ($group -ne $null) {
# Get group members
$groupMembers = Get-ADGroupMember -Identity $group
# Display group members
Write-Host "Members of $groupName:"
$groupMembers | ForEach-Object { Write-Host $_.Name }
# Get and display ACLs for the group
Write-Host "ACLs for $groupName:"
Get-Acl "AD:$($group.DistinguishedName)" | Format-List
# If you need to get ACLs for each member
foreach ($member in $groupMembers) {
Write-Host "ACLs for member $($member.Name):"
Get-Acl "AD:$($member.DistinguishedName)" | Format-List
}
} else {
Write-Host "Group not found"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment