I'm running into an issue where my Powershell code isn't working.
$pathToJsonFile='C:\Users\<redacted>\'
$InputFile= Read-Host -prompt 'Specify a target file'
$OutputFile= Read-Host -prompt 'Specify a destination file'
((Get-Content -Path $pathToJsonFile$InputFile) | ConvertFrom-Json -Depth 64).results | ConvertTo-Csv -NoTypeInformation | Set-Content $pathToJsonFile$OutputFile
The error I keep getting is:
4 | … om-Json -Depth 64).results | ConvertTo-Csv -NoTypeInformation | Set-C … | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Cannot bind argument to parameter 'InputObject' because it is null.
I'm not sure what the issue is since I'm piping one result into another. Referencing this post: Convert JSON to CSV using PowerShell
I'm also not sure what Depth is used for because I have two-layers of nested JSON I'm trying to get to do the conversion correctly.