I am using PowerShell to call the GitHub API. The result is a JSON array which I convert to a PowerShell object using ConvertFrom-Json cmdlet. This gives me a PowerShell array of objects. However when I pipe this directly to Select-Object I get nothing:
Invoke-WebRequest -Uri "https://api.github.com/organizations?per_page=3" | ConvertFrom-Json | Select-Object -Property login, id
However if I put the ConvertFrom-Json result into a variable, and then pass the variable to Select-Object, it works:
$json = Invoke-WebRequest -Uri "https://api.github.com/organizations?per_page=3" | ConvertFrom-Json
$json | Select-Object -Property login, id
I am mystified. Why does the one-line version not work?