PowerShell 2.0 introduced an interesting feature, the ability to execute PowerShell cmdlets remotely from a client machine without having to be at the console of a server or use a server control tool such as the Remote Desktop Protocol (RDP). To run a cmdlet from a remote location, make sure every server has the identical PowerShell version (2.0 or later), and run the following script before running cmdlets. Run the following code on every server in a SharePoint farm. (Be sure to start the PowerShell shell as an administrator by right-clicking on the PowerShell icon and choosing Run as administrator):
# Enables PowerShell Remoting
Enable-PSRemoting –force
# Enables credential delegation
Enable-WSManCredSSP –role Server –force
# Increases memory buffer size
Set-Item WSMan:localhostShellMaxMemoryPerShellMB 1000
Use the following code to enable remoting on a client machine (replace SPServer1
, SPServer2
with the actual names of the SharePoint servers in the farm):
The following code sample demonstrates how to execute Get-SPSite
on a remote computer. During execution, users will be prompted for the SharePoint administration credentials. Replace SPServer
with the actual SharePoint server name: