Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Need Group Name when exporting members of the group to a CSVgrp

$
0
0

Hello,
I trying to export a list of group members from multiple groups.
I need export the groupname with the user name.
When I run my script I get blanks or Microsoft.ActiveDirectory.Management.ADPropertyValueCollection in the groupname column.
grp1     joe
grp1     sally
grp1     jose

What am I doing wrong ?

Clear-Host#Get-ADGroupMember -Identity administrators | Select-Object name | Export-Csv c:\temp\administrators.csv$remotegrps=gcc:\temp\remotegrps.txtforeach ($remotegrpin$remotegrps) 
{Get-ADGroupMember-identity$remotegrp-Recursive | foreach{ get-aduser$_} | select$remotegrp, name |Export-Csv-appendc:\temp\remotegrps.csv-NoTypeInformation

}

Viewing all articles
Browse latest Browse all 6937

Trending Articles