Manipulate property and use in sort-object

192 Views Asked by At

I need to modify content in Powershell property Description and then use the content in Sort-Object, how can this be done ? Below is my sample, which is not working:

Sort-Object -Property $($_.Description).Split(":")[2].Trimend(")") -Descending
1

There are 1 best solutions below

0
On BEST ANSWER

Wrap your calculated property expression in {}:

Sort-Object -Property {$_.Description.Split(":")[2].TrimEnd(")")} -Descending