Powershell -expandproperty syntax issue

Anonymous
2017-04-13T09:30:44+00:00

The following Powershell command does not give the results expected:

get-recipient | Select-Object -property DisplayName -ExpandProperty emailaddresses

As per (example 2):

https://msdn.microsoft.com/powershell/reference/5.1/Microsoft.PowerShell.Utility/Select-Object

What am I doing wrong?

Thanks in advance

David (Nobby) Barnes

Microsoft 365 and Office | Subscription, account, billing | For business | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Anonymous
    2017-04-24T20:44:10+00:00

    Hi David,

    After consulting our related team, we can achieve your goal via the following “piped-command”:

    Get-Recipient |ft Displayname, RecipientType, PrimarySmtpAddress, EmailAddresses –Wrap

    Thanks,

    Gary

    1 person found this answer helpful.
    0 comments No comments

12 additional answers

Sort by: Most helpful
  1. Anonymous
    2017-04-13T13:19:32+00:00

    Hi David,

    About the cmdlet in example 2, it gets information about the modules used by the processes on the computer as described in the article. However, we will get all the email addresses in the organization. Here is my example:

    Is the result same as yours? What do you want to achieve?

    Thanks,

    Gary

    0 comments No comments
  2. Anonymous
    2017-04-16T07:34:19+00:00

    Hi David,

    Can you provide the information I mentioned above when you have time?

    Thanks,

    Gary

    0 comments No comments
  3. Anonymous
    2017-04-18T12:35:20+00:00

    I get the same/very similar to you.

    what I was expecting was something like:

    DisplayName:     Fred Blogs

    EmailAddresses:  SMTP:******@blogs.com

                     smtp:******@blogs.onmicrosoft.com

    DisplayName:     Wilma Fredstone

    EmailAddresses:  SMTP:******@blogs.com

                     smtp:******@blogs.onmicrosoft.com

    ...

    The '-property displayname' just seems to be ignored

       get-recipient | Select-Object -property DisplayName -ExpandProperty emailaddresses

        -and-

       get-recipient | Select-Object -ExpandProperty emailaddresses

    Gives the same results !!

       get-recipient | Select-Object -property DisplayName

    Correctly gives a list of recipient display names

    This confuses me greatly

    Maybe I'm mixing classes or object types or some such..

    Thanks

    0 comments No comments
  4. Anonymous
    2017-04-19T06:44:48+00:00

    Hi David,

    Thanks for your reply. To achieve the goal, please run the cmdlet below to achieve your goal:Get-Recipient -ResultSize Unlimited | select DisplayName,EmailAddresses

    Note: you can also export the display name and email addresses to a .csv file by running this cmdlet:

    Get-Recipient -ResultSize Unlimited | select DisplayName,RecipientType,EmailAddresses | Export-Csv email-recipients.csv

    The .csv file is stored in C:\Windows\System32\WindowsPowerShell\v1.0.

    Thanks,

    Gary

    0 comments No comments