$File_to_check_for_correct_JSON_syntax = "$PSScriptRoot\appsettings.json" if (Test-Path $File_to_check_for_correct_JSON_syntax) { $File_contents_RAW_string = (Get-Content $File_to_check_for_correct_JSON_syntax -Raw).ToString() $Json_Object = $null $Json_Object = ConvertFrom-Json $File_contents_RAW_string if ($Json_Object) { Write-host "The syntax of the JSON file is OK: $File_to_check_for_correct_JSON_syntax" -ForegroundColor Green } else { Write-host "There is an error in the syntax of the JSON file: $File_to_check_for_correct_JSON_syntax" -ForegroundColor Red Write-host "To solve the error, we recommend that you remove any sensitive information from your file (i.e. usernames, passwords and hostnames), and use an online JSON validator, for example https://jsonlint.com/" -ForegroundColor Yellow Write-host "Alternatively, you can use a text editor that supports syntax checking for JSON files. For example, you can get 'Code Writer' from Microsoft Store." -ForegroundColor Yellow } } else { Write-Host "ERROR: The file does not exist: $File_to_check_for_correct_JSON_syntax" -ForegroundColor Red }