Export List of Ad group and its members on Single file

$groups = Get-Content path\grouplist.txt
foreach($Group in $Groups)
{
$users=Get-ADGroupMember -Id $Group
foreach($user in $users)
{
add-content -Path patht\userlist.txt -Value “$group,$($user.samaccountname)”
}
}

Are you getting any trouble with the provided code ? and it will be better to format the code when posting in the forums :slight_smile: