Created
January 25, 2024 18:16
-
-
Save joshfinley/d11cc0db8f2552c20456322202b9926b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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