Created
September 20, 2023 09:34
-
-
Save mdanshin/bcfcbf448bb1a53dc05cb42d87ea6b1d to your computer and use it in GitHub Desktop.
Get all Active Directory groups with Manager Can Updated Membership List checkbox.
This file contains hidden or 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
$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