"Invalid array passed" when parsing JSON
Alternatively you can use Get-Content -Raw
which will retrieve the JSON as a single string.
See this post for more info: http://blogs.technet.com/b/heyscriptingguy/archive/2014/04/23/json-is-the-new-xml.aspx
Try to pipe to Out-String
before piping to ConvertFrom-Json
:
Get-Content $file | Select -Skip 1 | Out-String | ConvertFrom-Json
In your working example the JSON code is a string while the non-working example returns a collection of lines. Piping to Out-String
converts the collection to a single string, which is what the InputObject parameter accept.