Skip to content

Instantly share code, notes, and snippets.

@mdanshin
Created September 20, 2023 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdanshin/bcfcbf448bb1a53dc05cb42d87ea6b1d to your computer and use it in GitHub Desktop.
Save mdanshin/bcfcbf448bb1a53dc05cb42d87ea6b1d to your computer and use it in GitHub Desktop.
Get all Active Directory groups with Manager Can Updated Membership List checkbox.
$groups = Get-ADGroup -Filter *
$result = @()
foreach ( $group in $groups ) {
$object = Get-ADObject `
-Identity $group.DistinguishedName `
-Properties managedBy
if ( $object.managedBy -ne $null ) {
$managedBy = Get-ADUser -Filter "DistinguishedName -eq '$($object.managedBy)'"
$acl = Get-Acl "AD:\$($object.DistinguishedName)"
foreach ( $acc in $acl.Access ) {
$value = $acc.IdentityReference.Value
$ActiveDirectoryRights = $acc.ActiveDirectoryRights
if ($value -like "*\$($managedBy.SamAccountName)") {
if ($ActiveDirectoryRights -like "WriteProperty") {
$result += [PSCUSTOMOBJECT]@{
GroupName = $object.Name
managedBy = $managedBy.Name
}
}
}
}
}
}
$result | ft -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment