I’ve got two machines and they aren’t in a domain. One is my normal development machine – a nicely configured Windows 8.1 laptop from Lenovo. It isn’t beefy enough to run a complete SharePoint environment, so I have an extra dual-processor machine with lots of disk and lots of memory that runs Hyper-V. It’s sitting less than 10 feet away. However, that might as well be a world away from a management point of view. I want to manage it remotely from my laptop. Enter PowerShell Remoting. Getting this to work is a trick though. In this article, I’ll walk you through how to do it.
Step 1 – Configure The Network Profile
This was, for me, the painful bit. Everything else has been documented elsewhere. In short, there are three network profiles – Public, Private and Domain. You cannot have a Public network. Everything needs to be Private.
On Windows 8.1 (my laptop), I used Windows+I to open up the Settings charm and then selected the network icon (the top-left icon of the six icons down the bottom of the charm). At the top of the charm will be the string “View Connection Settings” which will take you into the “Settings” app under Network->Connections. Click on the name of your connection to get to the detailed information about your connection. Note the On/Off Slider under Find Devices and Content? Make sure that is On.
On Windows Server 2012 R2 (my server), I took a look at the network firewall – it already said it was “Private” and the Firewall was “On”, so that’s the default case there.
Step 2 – Enable PSRemoting
Both systems must have PSRemoting enabled. This is done through an elevated PowerShell prompt – just right-click on your PowerShell icon and select “Run as Administrator”. Then enter the command:
Step 3 – Add the Server to your Clients Hosts Table
This is not optional. You need to be able to resolve the servers IP address by hostname on the client (i.e. the laptop). The easiest way to do this is to add it to the hosts table. Just edit C:\Windows\System32\drivers\etc\hosts on the laptop and add a line like this:
Replace the IP address and hostname with your servers actual IP address and hostname. A bonus advantage is that you can RDP to your host by name.
Step 4 – Trust Your Server
This is the bit I could find a fair amount of documentation available online. You need to add your server name to the list of trusted hosts. Still on the laptop and still with an elevated PowerShell prompt, type the following:
Set-Item WSMan:\localhost\Client\TrustedHosts -Value myserver -Force Restart-Service WinRM
Once the WinRM service has restarted, you are good to go.
Step 5 – Connect to the Server
There are a couple of adjustments. For instance, you probably need to specify credentials. Here is my Enter-PSSession now:
Enter-PSSession -ComputerName myserver -Credential (Get-Credential)
Enter Administrator and your server administrator password and you should be in.