Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
the1gadget
Yak Posting Veteran
55 Posts |
Posted - 2009-03-16 : 08:41:26
|
Hi All(apologies if this is the wrong forum)I have a Job that is a Power shell script. This script works perfectly as a ps1 script when run from the command line, but when trying to run it from a job it gives me a syntax error.Does any one have any ideas as to where to start looking. here is the function====================================8<====================================function Try{ param ( # Check that the script blocks are there [ScriptBlock]$Command = $(throw "The parameter -Command is required."), [ScriptBlock]$Catch = { throw $_ }, [ScriptBlock]$Finally = {} ) &{ # Set the error trapping $local:ErrorActionPreference = "SilentlyContinue" trap { trap { & { trap { throw $_ } &$Finally } throw $_ } $_ | & { &$Catch } } &$Command } &{ trap { throw $_ } &$Finally }}====================================8<====================================The error it is barfing up at is the first line that has [ScriptBlock] on it. |
|
the1gadget
Yak Posting Veteran
55 Posts |
Posted - 2009-03-16 : 08:44:01
|
Hi AllYes wrong forum as it is 2008 server.:) |
 |
|
|
|
|