-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRun-JsonValidator.ps1
More file actions
25 lines (22 loc) · 932 Bytes
/
Run-JsonValidator.ps1
File metadata and controls
25 lines (22 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
clear-host
$script_path = $MyInvocation.MyCommand.Path
$script_dir = Split-Path -Parent $script_path
$jsonFiles = (Get-childitem -Path $script_dir -Recurse -Filter "*.json").FullName
ForEach ($JF in $jsonFiles)
{
Write-Host " --- --- --- --- --- --- ---" -ForegroundColor white
Write-Host "Prcessing $JF" -ForegroundColor Magenta
try {
$validJson = Convertfrom-Json -inputobject (GC $JF -Raw) -ErrorAction Stop;
} catch {
$validJson = $false;
}
if (!($validJson -eq $false)) {
Write-Host " + json formatting is correct" -ForegroundColor Green;
} else {
Write-Host " + json formatting is incorrect !! plesae check file $JF" -ForegroundColor Red -Backgroundcolor Black;
}
}
Write-Host " --- --- --- FINISH --- --- --- ---" -ForegroundColor white
Write-Host "Press any key to continue..."
$a = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")