I want to retrieve the SamAccountName from a number of ~600 AD groups that end with a certain string.
For example:
AD Groups:
AAA-BBB-XXX
CCC-DDD-XXX
EEE-FFF-XXX
Now I want to get the SamAccountName of all AD groups that end with XXX but also, with a relation between SamAccountName and AD-group so that I know to which AD-group they belong. So:
SamAccountName | AD GROUP
------------------------------
Bernie.Sanders | AAA-BBB-XXX
Donald.Trump | AAA-BBB-XXX
Barack.Obama | AAA-BBB-XXX
Joe.Biden | CCC-DDD-XXX
I have managed exporting all XXX AD-groups to .csv with -like and -filter operator. I have managed exporting all SamAccountName using Get-ADGroupMember and -identity operator.
But, I'm not able (yet) to create the above list as I'm a PS newbie. I'm looking for some 'where' statement and require some guidance.
Thanks