Link to home
Start Free TrialLog in
Avatar of Parity123
Parity123Flag for United States of America

asked on

Powershell : Group members export

Hello experts,

I have the following script and I need to output the members to a csv file with the format, GroupName, username.
For instance:
Group1, testuser1
Group2,testuser2
Group2,testuser1

$G = Get-AdGroup -filter "name -like 'test*'" -properties samaccountname

foreach ($group in $G) {
get-adgroupmember -identity $G.samaccountname | export-csv ./test.csv
}

Looking forward to your assistance.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Parity123

ASKER

Thanks