I have a script that currently grabs all the members of the domain admins group. If there are any nested groups it puts all the members of these in to a list in a CSV.
Get-ADGroupMember -identity “Domain Admins” -recursive | select name | Export-csv -path C:\Output\Groupmembers.csv -NoTypeInformation
How do I get this it to display the name of the group the user was nested in beside their name in the CSV?
This would then show the users name and what group they were nested in.
-recursivedoesn't support this. You need to write your own recursive-function