I am trying to export a list (.csv) with all the Active Directory groups beginning with "AD-Group-Mailbox*" in one column and the corresponding nested users per group in another column.
So far, I've managed to export a list of users only for a single group:
Get-ADGroupMember AD-Group-Mailbox-Parking | sort name | select name
But I can't understand how to do the same export at once for all the ad-groups beginning with "AD-Group-Mailbox*". There are over 200 and I try to avoid doing every single export manually.
CodePudding user response:
Variant:
Get-ADGroup -Filter '(Name -like "AD-Group-Mailbox-*")' |
ForEach-Object { Get-ADGroupMember -Recursive -Identity $_ } |
Select-Object -ExpandProperty 'Name' |
Sort-Object -Unique