In a PowerShell script, I read a config file and run some SQL queries. This works fine if I copy the code and paste it into PowerShell ISE.
But if I run the script by right clicking the file > Run with Powershell, I get an error
Invoke-Sqlcmd : Incorrect syntax near '¦'
I only get this error if the query contains scandinavian characters 'æøå'.
$config = Get-Content -Path <path to file>\config.json | ConvertFrom-Json
$server = $config.server
$database = $config.database
Invoke-Sqlcmd -ServerInstance $server -Database $database -QueryTimeout 0 -Query "select Næringskode from Virksomhet"
config.json
{
"server": "localhost",
"database": "MyDatabase"
}