I have a Powershell script I run which allows me to enter a Active Directory User's name and retrieve the groups they are a member of. I then output that to a file that shows the Group name, and GroupCatagory. I need to add additional functionality to this script. I need to get the email address of any group the target user is a part of and add it as a column to the text file that is created. This is in an Exchange 2003 environment so I am trying to get the information from AD. My script is below. Can some recommend how to add that information to the text file the script generates?
$Destination = "$Env:userprofile\Desktop
Write-Host "Please enter the target user's Active directory username"
$Username = Read-Host
Get-ADPrincipalGroupMembership $Username | select name, GroupCategory > $Destination\"$Username.txt"