Sometimes, it’s just nice logging into a remote computer to get an interactive environment where you can just type away some commands, either command line or PowerShell cmdlets, to get what you need without physically touching that computer or using Remote Desktop.
With WinRS/WinRM enabled on Windows, you can take advantage of features like PowerShell remoting to easily manage a string of remote Windows computers in a Command Prompt or PowerShell session, just like you do so via an SSH channel.
Enabling WinRM on Windows PC
Before you start, you need to get the remote computer prepared for PowerShell remoting feature. To get a single PC configured for WinRM and PS-Remoting, simply open an elevated PowerShell console and run the following command.
The cmdlet takes care of everything that needs to be set up for WinRM.
If you are configuring a larger network in a Windows Domain, Group Policy will be your friend to make your life a lot easier. There are three parts with quite a few steps that you need to go through. This guide should help you walk through this process.
Once all configured, the remote computer should have the port 5985 open and listen for any incoming calls. You can quickly test it and see if it’s ready.
Test-NetConnection -ComputerName remote_computer -Port 5985
2 ways to start an interactive session
There are two ways that you can try to open a remote interactive session where you can run the command lines against the remote computer.
You can use the Enter-PSSession cmdlet that comes with PowerShell to start an interactive session.
Enter-PSSession -ComputerName remote_computername
Then use Exit-PSSession to end the interactive session once done.
You can also use the cmdlet WinRS to fire up a remote session as well.
WinRS -r:remote_computer Command
With WinRS cmdlet, you can open a remote Command Prompt session by running a cmd as the command.
WinRS -r:remote_computer cmd
That’s about it for now. Hope you enjoy.