PowerShell script not working from SQL Job step

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Don Jones Don Jones 6 months, 2 weeks ago.

  • Author
    Posts
  • #61366
    Profile photo of Paul Fallows
    Paul Fallows
    Participant

    Hi

    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?

    Thanks
    Paul

  • #61548
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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.