List of Members per Group to CSV

Hi All,

How do you export this to a csv file.

Get-PWGroup | %{ Write-Host $_.GroupName:; $_ } | Get-PWGroupMember

I've tried a few different way's and can only get the list to come out not the group headings

$groupmemberspath = 'C:\temp\Export PWGroupMembers.csv'
Get-PWGroup | %{ Write-Host $_.GroupName:; $_ } | Get-PWGroupMember | Export-CSV -path $groupmemberspath

End game is to get a CSV with a full list of groups with users in each group.

Thanks
Ray