Email this to a friend
 
posted on October 12th 2016, at 15:46
by lunarg
I found this little snippet online that allows you to preparse your Powershell scripts to ensure there are no syntax errors in it. This is useful if you need to know the script is error-free but are otherwise unable to run it.

Source: https://rkeithhill.wordpress.com/2007/10/30/powershell-quicktip-preparsing-scripts-to-check-for-syntax-errors/# Contents of file TestScript.ps1param($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 "  ...

Send a link to this post to yourself or a friend.

Send to e-mail:
Your name:
Your e-mail:
Captcha:
Type the letters and numbers as shown.
/get/captcha/1711667898
Not readable? Get another.
 
Information entered is solely used for sending a one-time e-mail, and is not retained and/or passed on to a third party.
 
 
 
 
« March 2024»
SunMonTueWedThuFriSat
     12
3456789
10111213141516
17181920212223
24252627282930
31      
 
Links
 
Quote
« I needed a password with eight characters so I picked Snow White and the Seven Dwarves. »