≡ Menu

How to enable remoting in PowerShell V2

PowerShell V2 supports remote administration. That means, you can execute commands, scripts, powershell cmdlets remotely on PowerShell V2 installed computers(Windows 7 & 2008). So, in this post I am going to talk about enabling remoting feature in PowerShell V2.

It is pretty simple and straight forward process.

To enable remoting on a computer, issue the below command in powershell window

Enable-PSRemoting -force

This will configure WinRM related components and adds rules in Windows Firewall to allow WinRM communication. Once it is enabled, you can test the functionality by issuing below command.

Invoke-Command -ComputerName [remotehostname] { get-services }

The above command will display list of services available in remote machine if remoting is working on it.  You can also write your own function to test the remoting status of remote machine(one example is here )

You can invoke the execution of a batch file in remote machine and bring output to your machine by using below example.

Invoke-Command -ComputerName [remotecomp] { cmd.exe /c “c:temptest.bat” }

Hope this helped you to some extent.

Happy Learning..,
Sitaram Pamarthi