7,023 questions
Something like this?
Get-ADGroup -filter "name -like '*_*'" | # matches _ABC, ABC_, ABC_DEF . . . I.E., anything with a _ character in the name
ForEach-Object{
$n = $_.name
$m = @()
Get-ADGroupMember $_.DistinguishedName |
ForEach-Object{
$m += $_.SamAccountName
}
[PSCustomObject]@{
GroupName = $n
Members = $m -join ";"
}
} | Export-Csv c:\junk\mem.csv -NoTypeInformation