Manipulate property and use in sort-object

201 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 answers

0
Mathias R. Jessen On BEST ANSWER

Wrap your calculated property expression in {}:

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