Skip to content

Commit

Permalink
Update Invoke-ADEnum.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo4j authored Aug 25, 2024
1 parent 37c4ae3 commit 2b67607
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Invoke-ADEnum.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7115,13 +7115,16 @@ Add-Type -TypeDefinition $efssource -Language CSharp
$computers = @($TotalEnabledMachines | Where-Object { $_.domain -eq $AllDomain -AND $_.distinguishedName -like "*,${ouDN}" } | ForEach-Object { $_.samaccountname })

# Filter groups within this OU
$groups = @($TotalGroups | Where-Object { $_.domain -eq $AllDomain -AND $_.distinguishedName -like "*,${ouDN}" } | ForEach-Object { $_.samaccountname + "(Grp)" })
$collgroups = @($TotalGroups | Where-Object { $_.domain -eq $AllDomain -AND $_.distinguishedName -like "*,${ouDN}" } | ForEach-Object { $_.samaccountname + "(Grp)" })

# Filter orgunits within this OU
$orgunits = @($AllCollectedOUs | Where-Object { $_.domain -eq $AllDomain -AND $_.distinguishedName -like "*,${ouDN}" } | ForEach-Object { $_.name + "(OU)" })

# Filter orgunits within this OU
$collforeign = @($AllForeignSecurityPrincipals | Where-Object { $_.domain -eq $AllDomain -AND $_.distinguishedName -like "*,${ouDN}" } | ForEach-Object { $_.name + "(Foreign)" })

# Combine users and computers
$members = @($users + $computers + $groups + $orgunits) -join ' - '
$members = @($users + $computers + $collgroups + $orgunits + $collforeign) -join ' - '

# Create a custom object for each OU with its members
[PSCustomObject]@{
Expand Down

0 comments on commit 2b67607

Please sign in to comment.