I just want to make sure it's not some behavior of some powershell command that causes this issue.
I make an API call and for some reason when a JSON object is too long, it just gets cut off. This results in incomplete JSON, breaking the rest of the file.
(Microsoft.Exchange API)
(Search-UnifiedAuditLog -StartDate $startDateTime -EndDate $endDateTime -RecordType $recordType | Select-Object AuditData).AuditData | Out-File .\API_Dump_Broken.json
I tested it with as few code as possible, to make sure it's not an issue with my code.
(Fake) example of the JSON result:
{"CreationTime":"2019-02-16T12:50:37","Id":"068ca975-72a1-40c4-171d-08d6959fae97","Name":"Formaldehyde"}
{"CreationTime":"2019-02-17T12:50:37","Id":"068ca975-72a1-40c4-171d-08d6959fae97","Name":"OxyMethylene", "Language": "Powershell", "Message": "This is getting cut o
{"CreationTime":"2019-02-18T12:50:37","Id":"068ca975-72a1-40c4-171d-08d6959fae97","Name":"Methanal"}
The second record is getting cut off, while the others are technically fine. Ofcourse the 3rd record is now broken, because the second one got cut off.
Does Select-Object or Out-File limit the amount of characters returned in any way? Or is this really an issue of the API just cutting off the JSON objects and can I go complain to the devs :)
Thanks in advance!
Michael