I am doing a script that creates a csv of distribution group memebership. A snippet:
$list = Get-DistributionGroup -Identity grp1 | Get-DistributionGroupMember | Select-Object -Property Name,Alias,ExternalEmailAddress,RecipientType | Add-Member -MemberType NoteProperty -Name Group -Value "grp1" -PassThru $list += Get-DistributionGroup -Identity grp2 | Get-DistributionGroupMember | Select-Object -Property Name,Alias,ExternalEmailAddress,RecipientType | Add-Member -MemberType NoteProperty -Name "Group" -Value "grp2" -PassThru
The ExternalEmailAddress property is an object. It outputs a sting in the format of "SMTP:jdoe@contoso.com". There is a property of the object called AddressString that just has jdoe@contoso.com. That is what I would like to grab and export. So my thinking is to find the correct syntax for this command:
Select-Object -Property Name,Alias,ExternalEmailAddress.AddressString,RecipientType
Is there a way to do this directly with Select-Object? If not, what is the best way to get the result I want: A csv with the email field that isn't prepended with "SMTP:".