IN_GROUP
Summary
Description
Identification
PowerShell
Active Directory Module
function Find-IN_GROUP {
[CmdletBinding()]
param ( [string]$GroupDN = $null, [string]$OutputPath = "ADGroupsMembers.csv")
Import-Module ActiveDirectory -ErrorAction Stop
$results = @()
try {
if ($GroupDN) {
Write-Host "Scanning specific group: $GroupDN"
$memberNames = (Get-ADGroupMember -Identity $GroupDN -ErrorAction SilentlyContinue |
Select-Object -ExpandProperty Name) -join ';'
$results += [PSCustomObject]@{
GroupName = $GroupDN
Members = $memberNames
}
}
else {
Write-Host "Scanning all groups in the domain..."
$groups = Get-ADGroup -Filter * -ErrorAction Stop
foreach ($group in $groups) {
$memberNames = (Get-ADGroupMember -Identity $group.DistinguishedName -ErrorAction SilentlyContinue |
Select-Object -ExpandProperty Name) -join ';'
$results += [PSCustomObject]@{
GroupName = $group.Name
Members = $memberNames
}
}
}
}
catch {
Write-Error "Failed to enumerate groups: $($_.Exception.Message)"
return
}
if ($results.Count -gt 0) {
Write-Host "Found $($results.Count) group record(s)."
try {
$results | Export-Csv -Path $OutputPath -NoTypeInformation -Encoding UTF8 -ErrorAction Stop
Write-Output "Results exported successfully to '$OutputPath'"
}
catch { Write-Error "Failed to export results to CSV file '$OutputPath': $($_.Exception.Message)" }
}
else { Write-Output "No groups or members found."}
}Active Directory Users and Computers (GUI)
Exploitation
Windows
Mitigation

Detection
Event ID
Description
Fields/Attributes
References
References
Last updated
Was this helpful?