Have a powershell script to pull alerts from graph api and converts it to a JSON file. The JSON file has to be flat (ConvertTo-Json -Compress) for use in a different system. The script works great when it only returns a single alert if multiple alerts are returned instead of a json file with 2 lines I have one really long line.
How can I get the output to a single file with a line for each json
$response = Invoke-WebRequest -Method Get -Uri $url -Headers $headers -ErrorAction Stop
$alerts = ($response | ConvertFrom-Json).value | ConvertTo-Json -Compress -Depth 100
$alerts = $alerts -replace "\\n\\n", " "
$outputJsonPath = "$path\test.json
Out-File -FilePath $outputJsonPath -Encoding ascii -InputObject $alerts