We all know PowerShell is mostly used by SharePoint admins to manage their servers in a farm. SharePoint admins perform many activities as part of the SharePoint administration. In this article, we will learn how to execute remote PowerShell commands from one server on a remote server.SharePoint-2013-Hosting1

Why do we need this remote execution of PowerShell script?

  • Managing multiple servers and running a command on every server individually is time-consuming.
  • Centralized server (one server) to run a script on all remote servers gives more control over process.
  • Prevents uneccessary access to all servers.
  • Tighter and secure environment.
  • Single script to run on one machine and updating multiple servers at once.

Use case

For the sake of the article, we will take an example on how to deploy WSP from client to SharePoint Server A.

Setup Remote Server

Check if WINRM service is started and running. Go to services.msc and see if Windows Remote Management (WS-Management) service is running.

Enable PowerShell Remoting. Run the below command in PowerShell (as administrator).
Enable Server as Remote server. Run the below command in PowerShell (as administrator).

Run the below 2 commands one after another.

  • Firewall rule must be enabled to allow communication with the server.
  • Ensure the user has permission to SharePoint content database.

Setup Up Client machine

Enable PowerShell Remoting. Run the below command in PowerShell (as administrator).

Enable Client. Run the below command in PowerShell (as administrator).

We have configured the client to run remote commands on any remote server.
Run commands from the client machine.
Get user credentials and store in variables.

Enable SSP and Get Session object to enter to remote server.

Run command via -ScriptBlock attributes. Using script block, you can run multiple commands at once on a remote server.

Now, enter the session of the remote server.

On successfully running this, it will run all the invoke commands on the remote server. Go to the server and check if WSP is updated.

Using the Invoke-Command method, you can run any command available and it will execute in the remote server.
Examples of other commands.


In this article, we have learned how to enable remote execution of PowerShell script on SharePoint server and in an example, deployed WSP rom the client to a SharePoint Server.