Monday 5 March 2012

PowerShell remoting

PowerShell remoting gives you the ability to run powershell scripts remotely on another machine.
Pretty cool if you have to run recurring scripts on multiple machines from your own PC.



On your target server ::
Open a powershell window as admin and run the following commands in blue

Enable-PSRemoting
Accept all prompts

Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 1000
Accept all prompts

Enable-WSManCredSSP –Role Server
Accept all prompts



If your account running the script needs ShellAdmin permissions to run the script, check if the account is shell admin with the following on your target server. This was only relevant to what I was doing in SharePoint, ignore if not applicable.
get-spshelladmin

If its not listed, add the account to shell admin on the target server.
add-spshelladmin accountname


Add the account (or SP account in my case) used to run code to the server local admin group.
In case of a multi-server farm, add on all servers. This again may not be relevant in your case.



On your Client Server ::
(where you want to run your script)
Open a powershell window as admin and run the following commands in blue
 
Enable-WSManCredSSP -Role client -DelegateComputer *


Test access from the client server to the target server by entering the following PS command in a PS window
Enter-PSSession -ComputerName servername -Authentication CredSSP -Credential domain\accountname




All thanks to Abid the code Yoda and this URL :
http://blogs.msdn.com/b/opal/archive/2010/03/07/sharepoint-2010-with-windows-powershell-remoting-step-by-step.aspx

No comments:

Post a Comment