Link to home
Start Free TrialLog in
Avatar of SAM2009
SAM2009Flag for Canada

asked on

How to sort PowerShell Format-List result?

Hi,

How to get the result of this cmd but sorted:

Get-Recipient -RecipientType MailContact -Identity "UserName" | fl
Avatar of oBdA
oBdA

You can't. You don't. You're not supposed to.
The Format-* cmdlets are (usually) meant to be the last element of the pipeline. They only format the output, basically destroying the original objects.
The solution: sort before the Format-* cmdlets.
Get-Recipient -RecipientType MailContact -Identity "UserName" | Sort-Object -Property Whatever | Format-List

Open in new window

Avatar of SAM2009

ASKER

No it doesn't sort. Same result.
Of course you need to tell which property to use for sorting. "Whatever" is a placeholder ;-).
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SAM2009

ASKER

Thanks!