SQL Powershell Module is not installed on your agent machine. Please follow steps given below to execute this task

Viewed 2934

We're using TFS 2018 (Update3.2) to do continuous integration and deployment. I have a release definition where we do a SQL deployment (run a SQL file) and IIS deployment.

enter image description here

IIS deployment works but the SQL deployment fails saying "SQL Powershell Module is not installed on your agent machine...". I installed the SQL Server PowerShell module, restarted the server, recreated the agent but still getting the same error. SQL PowerShell module is installed on the TFS and web server. Does it have to be installed on SQL server as well? Am I missing anything? Please help.

enter image description here

2 Answers

SQL Powershell Module is not installed on your agent machine. Please follow steps given below to execute this task.

Testing the same steps, I also encountered this issue. To solve this issue, you need to install sql server module. (Script Install-Module -Name SqlServer)

From you comment, you have added this module but still have this issue.

You could try the following steps:

  1. Uninstall the module(Uninstall-module -Name SQLServer). Then re-install the module for all users.

Install-Module -Name SqlServer -Scope AllUsers

Powershell

  1. Restart the Agent Service in Local System-> Services.

enter image description here

After these steps, you could run the build again and check if it could work.

In addition,you also could create a new target agent in Deployment Group.

From this ticket, the new agent seems to solve this issue.

Hope this helps.

I had to install SqlPackage.exe also for it to work.

Here are the steps I followed:

  1. Install SqlPackage.exe (x86 and x64)
  2. Install SQL Server PowerShell module
  3. Restart the Agent Service

enter image description here

Related