Managing Nano and Core with PowerShell remoting

Now we move on to the most powerful way that we can interact with our remote and headless servers, PowerShell. If I've said it once, I've said it a thousand times - PowerShell has the capability to change anything in the operating system; it's just a matter of figuring out the right commands and cmdlets to use. By establishing a remote PowerShell connection to a server, you can manipulate any facet of that machine right from the pretty blue window that is running on your local computer. In this recipe, we will use PowerShell from both a Windows Server 2016 running Desktop Experience and from a Windows 10 client computer.

Getting ready

As we continue to figure out how to remotely manage our new CORE1 and NANO1 servers, we will now be using PowerShell from both our CA1 server and from our Win10 client computer to see what we can or cannot accomplish with these two servers.

How to do it…

Since we are already logged into the CA1 server, let us try to launch a remote PowerShell connection to CORE1 from inside Server Manager. If you are already logged into a server, or if you have installed RSAT to give yourself Server Manager on your local computer, this is a quick and easy way to establish PowerShell remoting:

  1. Launch Server Manager. We are going to assume that you have already used the Add Servers function so that you can see CORE1 inside the All Servers screen.
  2. Right-click on CORE1, and choose the option for Windows PowerShell.

    How to do it…

  3. After a couple of seconds where PowerShell is opening and creating a connection to CORE1, we are presented with a familiar blue PowerShell window. What that doesn't look standard is the fact that, in front of our flashing cursor, you can see the CORE1 server name specified. This indicates that our PowerShell window is actively running against CORE1, and anything that you type into this window reflects CORE1, and not the CA1 server that we are logged into.
  4. Let's prove this. As you can see in the following screenshot, I have System properties open and you can see that we are currently logged into my CA1 server which is running the full Desktop Experience version of Windows Server 2016. However, when I enter a simple hostname command into my remote PowerShell window, it responds that the system hostname is CORE1.

    How to do it…
  5. One final step here before we move on to our other example: let's try to change something on CORE1. Earlier we installed the Web Server role onto this system, but now I have decided to use this server for a different purpose. Rather than having to launch any graphical tools or wizards, since I already have this remote PowerShell session open I can remove the Web Server role from CORE1 with a single command:
      Remove-WindowsFeature Web-Server

How to do it…

Now let's change gears a little and move away from using a server to remotely manage our system. Instead, I am going to log into a regular Windows 10 client computer, which does not have any of the server tools installed, and use PowerShell right from there to remotely connect to my NANO1 server:

  1. Launch an administrative PowerShell session on the Win10 client.
  2. Use the following command to attempt connection to NANO1:
          Enter-PSSession -ComputerName NANO1
    

    How to do it…

  3. Uh oh, that's kind of a nasty error message. I double-checked the firewall configuration on NANO1, and even ran the process for resetting WinRM to the factory defaults, but I continue to get this message. Wait a minute, I know what's going on. I am running this PowerShell prompt from a domain login, but NANO1 is not yet joined to the domain! This means that PowerShell on my client is not trusting NANO1, because it cannot verify anything with Active Directory.
  4. Fortunately, there is a command I can run on my Win10 client that will tell PowerShell to specifically trust NANO1. I will now run this command:
          Set-Item wsman:localhostclient	rustedhosts NANO1
    

    Tip

    Note that this will not be required when connecting a remote PowerShell session to a domain-joined system.

  5. In addition to setting up the trust, I will also have to adjust my Enter-PSSession cmdlet parameters slightly. This is because I am running PowerShell inside my domain login, but NANO1 is not joined to the domain and so it will not yet recognize my domain credentials.
  6. In order to connect the remote PowerShell session while specifying local credentials that will actually authenticate to NANO1, try this command instead:
      Enter-PSSession -ComputerName NANO1 -Credential administrator

How to do it…

How it works…

We have now explored a variety of ways that you can remotely connect to and manipulate your headless servers such as Server Core and Nano Server. PowerShell is by far the most powerful way to accomplish this, but it is also the most complicated if you are not familiar with using PowerShell cmdlets in your everyday work. While a learning curve is involved, this is the best avenue to pursue as you enhance your IT capabilities.

It is important to note that Nano Server is still brand new, and is still evolving as a technology. The processes and procedures that you use to build and interact with new Nano Servers may change over the coming months as people settle into using Windows Server 2016 and Microsoft makes adjustments to improve it.

See also

If you have any interest in Azure, or even if you don't, make sure you check out the new cloud capability they are providing that helps you manage your servers. The Server Management Tools (SMT) are a collection of tools, which allow you to interact with all of your servers. You can manage Windows servers running Desktop Experience, or Server Core, or even Nano Server, and you can do it all from your web browser! Yes, this does involve logging into Azure, which means you need an Azure account, but this is one of their free offerings. You can connect both Azure virtual machines as well as your on-premise servers to SMT in order to view data about them and even make changes on them. Things as simple as shutting down or restarting a Nano Server can be complicated to figure out from your local desktop, but they are simply and easily done by using SMT.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.53.238