PowerShell script not working from SQL Job step

Welcome Forums General PowerShell Q&A PowerShell script not working from SQL Job step

This topic contains 1 reply, has 2 voices, and was last updated by

2 years, 2 months ago.

  • Author
  • #61366

    Points: 0
    Rank: Member


    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

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    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?

The topic ‘PowerShell script not working from SQL Job step’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort