Using Invoke-Sqmcmd on a network shared folder RRS feed

  • Question

  • Hi All.

    I would like to know if its possible to run sql files stored on a network share using Invoke-Sqlcmd, when i tried this I was getting some errors because the file is not located on a local file system.

    Wednesday, November 8, 2017 3:30 PM

All replies

  • invoke-sqlcmd -InputFile \\server\share\file.sql


    Wednesday, November 8, 2017 3:33 PM
  • Thanks for the reply, the issue I am having is that when using escape token to create SQL agent jobs, its clashing with SQLCMD. I am getting the error.

    invoke-sqlcmd : 'JOBID' scripting variable not defined
    At line:16 char:1


    Monday, November 13, 2017 11:49 AM
  • For issues with SQL Agent you need to post in the SQLServer forum.  As you have noted the command works when not run under the agent.

    Also there is not enough information to understand how you got there.  I do not believe that Invoke-SqlCmd is a good choice for the agent.


    Monday, November 13, 2017 6:42 PM