1

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.

1
  • -recursive doesn't support this. You need to write your own recursive-function Commented May 31, 2016 at 22:23

1 Answer 1

1

I know the post is old but I found the function that someone already created a to get nested groups and list the nested group name as you requested. there are different way to ran the function but I saved the script as a function and I imported when using import-module "C:\location of the modulegoeshere\PSM1"Please find the link for the script below, I saved script as a module and imported. so you code should look like this

import-csv "C:\temp\get-ADNestedGroupMembers

Get-ADGroup "MyGroup" | Get-ADNestedGroupMembers | select name, nested

https://gallery.technet.microsoft.com/scriptcenter/Get-nested-group-15f725f2.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.