In case you want to be a fully proven bomb, this is what I would advise:
@('Apples', 'Apples ', 'APPLES', 'Banana') | Sort-Object -Property @{Expression={$_.Trim()}} -Unique
Output:
Apples Banana
This uses the Property parameter for the first line of Trim() , so extra whitespace is removed, and then only -Unique values are selected.
Additional information about Sort-Object :
Get-Help Sort-Object -ShowWindow
DarkLite1 Jun 01. '17 at 10:58 on 2017-06-01 10:58
source share