NetworkScript/test-syntax.ps1

12 lines
517 B
PowerShell
Raw Permalink Normal View History

$files = @('NetworkAdapter.psm1','Set-NetworkAdapter.ps1')
foreach ($f in $files) {
Write-Host '---' $f '---'
$errors = $null
[void][System.Management.Automation.Language.Parser]::ParseFile((Join-Path $PSScriptRoot $f), [ref]$null, [ref]$errors)
if ($errors -and $errors.Count -gt 0) {
$errors | ForEach-Object { Write-Host ("Line {0}: {1}" -f $_.Extent.StartLineNumber, $_.Message) -ForegroundColor Red }
}
else {
Write-Host 'No syntax errors.' -ForegroundColor Green
}
}