I need to combine below results and output in to an csv file . Could some one please help.
$groupname = "ExampleGroupname"
$members = get-adgroupmember -identity $groupname
$memberof = get-adprincipalgroupmembership -identity $groupname
The result should be like
Unless your AD is small and fairly simple, squeezing that info into a csv can be problematic. This should help though. The member commands return objects and you are likely only interested in the samAccountname.