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

 
Keymaster
1 year, 11 months ago.

  • Author
    Posts
  • #61366

    Participant
    Points: 0
    Rank: Member

    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

    Keymaster
    Points: 1,673
    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.