header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left

[BANNER]

[BANNER]

This area of the Web site is freely editable by all registered users. When editing, expand the "Directions" item for instructions on creating and linking to new pages. Please help keep this area of the community neat and clean by adding appropriate edits and so forth.

This area of the Web site is freely editable by all registered users. When editing, expand the "Directions" item for instructions on creating and linking to new pages. Please help keep this area of the community neat and clean by adding appropriate edits and so forth.

Pre-Parsing Scripts


PreParsing Scripts

It isn't always possible to run a script to see if a change you made broke it.  In those cases, you can get PowerShell to tell you if there are obvious syntax errors using a script like this:

# Contents of file Test-Script.ps1
param($path, [switch]$verbose)

if ($verbose) {
    $VerbosePreference = 'Continue'
}

trap { Write-Warning $_; $false; continue }
& `
{
    $contents = get-content $path
    $contents = [string]::Join([Environment]::NewLine, $contents)
    [void]$ExecutionContext.InvokeCommand.NewScriptBlock($contents)
    Write-Verbose "Parsed without errors"
    $true
}

Note that this will not catch runtime errors but it is better than not doing any checking at all.

 




 |  View Topic History  |
right
footer   footer
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
footer   footer