I'm running a powershell script to get the results of a SQL query (in JSON format from SQL2016) and the results come back broken up into individual lines with '...' on the end instead of one JSON string and some header info at the top of the file. This makes the JSON unuseable.
I verified that this is on the PowerShell side by running the same query in SSMS and the results came out as expected (valid JSON)
I couldn't find any command line arguments for controlling the output of Invoke-SqlCommand
I'm new to PowerShell... Any ideas how to help me get clean JSON from this PowerShell script?
The powershell script:
Invoke-Sqlcmd -InputFile "C:\Dashboard\sql\gtldata.sql" | Out-File -filepath "C:\Dashboard\json\gtldata.json"
A sample of the returned document:
JSON_F52E2B61-18A1-11d1-B105-00805F49916B
-----------------------------------------
{"KPI":[{"BusinessUnit":"Water - Industrial","Location":"SPFIN","TestDate":"2016-09-19T21:11:10.837","TestResult":"Fail","FailReason":"P...
ial":"100161431","PumpType":"xxx","Stages":0},{"BusinessUnit":"Water - Industrial","Location":"SPFIN","TestDate":"2016-09-20T01:48...
"PumpType":"xxx","Stages":0},{"BusinessUnit":"Pre-engineered","Location":"SPSPA","TestDate":"2016-09-20T10:46:38.403","TestResult"...