In PowerShell 5.1, I am reading a JSON file into an array of objects and sorting them descending order by one property, but when I use a single statement, the sort does not save to the final variable. Breaking it into two statements works and I am curious why one works while the other doesn’t.
Here is my code:
WORKS:
$versions = Get-Content $jsonFilePath | Out-String | ConvertFrom-Json
$versions = $versions | Sort-Object -Descending -Property Version
NO WORKIE:
$versions = Get-Content $jsonFilePath | Out-String | ConvertFrom-Json | Sort-Object -Descending -Property Version