Sql-server – How to have SQL Server’s SQL Agent pick up a new Powershell module

powershellsql-server-2016sql-server-agent

I have a Powershell module that I've written and uploaded to my SQL Server at C:\Program Files\WindowsPowerShell\Modules.I have a SQL Agent job with a powershell step that calls the module. This all works and has been working.

However, I recently made a change to the way the Powershell module works. I updated the code and uploaded it to the server, but SQL Server seems to be executing the outdated version of the code still, even though the file has been replaced.

Do I need to tell SQL Server or Powershell to "refresh" the module somehow? How can I do that?

Best Answer

Do I need to tell SQL Server or Powershell to "refresh" the module somehow? How can I do that?

You can use import-module yourModuleName -Force.