1

I have a list of AD groups in a text files adgroups.txt:

Audit Internal_audit IT

I want to be able to have a CSV list:

Group Name Users

Nothing else. My poweshell script I am using is:

$groups = Get-Content c:\temp\ADGroups.txt foreach($Group in $Groups) { Get-ADGroupMember -Id $Group | select @{Expression={$Group};Label="Group Name"},* | Export-CSV c:\temp\GroupsInfo.CSV -NoTypeInformation 

This spits out WAY to much info.

Group name Distinguished name Name Object Class etc......

Should I use a select-object and only select group name and name?

1 Answer 1

1

You almost had it! Replace the * with name and it should give you what you are looking for.

Get-ADGroupMember -Id $Group | select @{Expression={$Group};Label="Group Name"},Name | Export-CSV c:\temp\GroupsInfo.CSV -NoTypeInformation -append 
Sign up to request clarification or add additional context in comments.

1 Comment

So close! Its only showing me the last group name on the list. it skipped over the other 2...?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.