Enable PSRemoting for SharePoint Servers

PSRemoting is a useful feature. Introduced with PowerShell v2, it remains one of the most useful features. It enables you to remotely login into any SharePoint server and do your work. However, SharePoint does not play very nice with the PSremoting like other MS servers like exchange.

You can use below steps to enable psremoting to correctly configure your SharePoint servers to allow certain users access to run SharePoint PowerShell cmdlets.

SharePoint Servers Setup:

    1. In Server Manager, add the user(s) to the following Groups:
      1. Remote Desktop Users
      2. WinRMRemoteWMIUsers__
      3. WSS_ADMIN_WPG
    2. Run the SharePoint Management Shell as Administrator and type below commands one at a time:
      1. Enable-PSRemoting -Force
      2. Enable-WSManCredSSP –Role Server
      3. winrm set winrm/config/winrs ‘@{MaxShellsPerUser=”25″}’
      4. winrm set winrm/config/winrs ‘@{MaxMemoryPerShellMB=”600″}’
      5. Get-SPShellAdmin (this should only return all the users who have the SharePoint_Shell_Access role)
      6. Add-SPShellAdmin -UserName -Database (Get-SPContentDatabase -Identity ). Replace with username and content database name appropriately. If user needs access to all databases, just use username paramter and remove the database one.
    3. Type Get-SPShellAdmin again. The user you added should now be listed.
    4. Type Set-PSSessionConfiguration -Name Microsoft.PowerShell32 –ShowSecurityDescriptorUI

This will open up a dialog box. Add the user(s) with Read and Execute permissions then click OK.

Remote Client setup:

Open Windows PowerShell as Administrator and run below commands one by one:

  1. Enable-WSManCredSSP -Role client -DelegateComputer
  2. $cred=Get-Credential. You can also choose to get credentials from a local file.
  3. $s=new-PSsession -authentication credssp -credential $cred

This should be enough to establish a session using invoke-command or enter a session using enter-psession. Let’s see this in work:

  1. Type Invoke-Command -Session $s -ScriptBlock {Add-PSSnapin Microsoft.SharePoint.PowerShell;}
  2. Type Invoke-Command -Session $s -ScriptBlock {get-SPContentDatabase |select name}

Output should be like this:

get-content-databases-name-using-psremoting
Get Content Databases name using PSRemoting

We can also get into remote session using PowerShell:

Enter-PSSession Output
Enter-PSSession Output

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s