I am trying to run a powershell script in server1 to deploy WSP file present in server2. Here is my code:

$password = ConvertTo-SecureString "password" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("username",$password)
Enter-PSSession -ComputerName server2 -Credential $cred
Add-PSSnapin Microsoft.Sharepoint.Powershell –EA 0
Update-SPSolution -Identity TechSoup.Web.wsp -LiteralPath "C:\Program Files ...Debug\Some.wsp" -GacDeployment 

I am successfully able to enter server2 using the first 3 lines. I now want to run the bottom two lines as administrator on server2 from server1. I am getting this error:

Update-SPSolution : Cannot access the local farm. Verify that the local farm is properly configured, currently available, and that you have the appropriate permissions to access the database before trying again.

Can anyone help me with this ?? I need to deploy the wsp solution remotely.

  • If someone can suggest a solution with executing remote script(remotely running the powershell script for deployment), that will also suffice. Jun 7, 2019 at 13:38
  • I believe the error is coming because I don't have admin privileges, because when I run the deployment code from server2 as admin, the wsp file is getting deployed successfully. Jun 7, 2019 at 13:54

1 Answer 1


I have found the answer here:


I hope this helps someone who needs this.

Here is how it worked for me:

On Client:

Enable-WSmanCredSSP -Role "Client" -DelegateComputer clientmachinename -Force

Also, go to gpedit.msc and look at the following policy: Computer Configuration -> Administrative Templates -> System -> Credentials Delegation -> Allow Delegating Fresh Credentials and Allow Delegating Fresh Credentials with NTLM. Enable the state and add SPN to Server List for Remote Server. In our case it will be: WSMAN/clientmachinename. Click Okay, save and exit.

On Server: (Where WSP file is present and needs to be deployed)

Enable-WSmanCredSSP -Role Server
winrm set winrm/config/winrs '@{MaxShellsPerUser="25"}'
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="600"}' 

Click Yes/Yes to all till the dialog box appear.

Now Our System is configured for Remote execution of Powershell command.

Once, this is done, go to Client and run this command:

$password = ConvertTo-SecureString "your password" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("username",$password)
Invoke-command -computername yourServerName -credential $cred -authentication CredSSP -scriptblock {Add-PSSnapin Microsoft.Sharepoint.Powershell –EA 0 
Update-SPSolution -Identity yourfile.wsp -LiteralPath "C:\Program Files (x86)\(location of your file)...\yourfile.wsp" -GacDeployment} 

The above script will deploy our wsp file to Server. Make sure that you run these commands in administrator mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.