PowerShell script not working from SQL Job step

This topic contains 1 reply, has 2 voices, and was last updated by  Don Jones 1 year ago.

  • Author
  • #61366

    Paul Fallows


    I have a script which creates a zip file and adds files to this. This works fine from PowerShell but when I add it to an SQL Job step it fails with Syntax error. It fails at the following line:

    set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))

    Any ideas why this is failing from the SQL Job step?


  • #61548

    Don Jones

    It's kind of overwrought syntax, so it's hard to tell. Since you didn't post the error message, I'm just guessing, but personally I'd get rid of all the string concatenation and just use double quotes and subexpressions. I'm also not sure what the [char] type forces are for.

    What this is doing is forcing "5" to be of the type [char]. Is that what you intended?

You must be logged in to reply to this topic.