Configuring Windows Server 2016 Core with and for PowerShell

February 14th, 2017 by and tagged , ,

I know I owe you more on creating a lab with PowerShell, and I’ll get to that in a few days. But having just set up a new domain controller running Server 2016 Core, I thought I’d include a couple of tricks I worked through to make your life a little easier if you choose to go with core.

First: Display Resolution — the default window for a virtual machine connected with a Basic Session in VMConnect is 1024×768. Which is just too small. So, we need to change that. Now in the full Desktop Experience, you’d right click and select Display Resolution, but that won’t work in Server Core, obviously. Instead we have PowerShell. Of course. The command to set the display resolution to 1600×900 is:

Set-DisplayResolution -Width 1600 -Height 900

This will accept a -Force parameter if you don’t like being prompted. A key point, however, is that it ONLY accepts supported resolutions. For a Hyper-V VM, that means one of the following resolutions:

1920x1080     1600x1050     1600x1200
1600x900      1440x900      1366x768
1280x1024     1280x800      1280x720
1152x864      1024x768       800x600

Now that we have a large enough window to get something done, start PowerShell with the Start PowerShell (that space is on purpose, remember we’re still in a cmd window.)  But don’t worry, we’ll get rid of that cmd window shortly.

Now that we have a PowerShell window, you can set various properties of that window by using any of the tricks I’ve shown before, such as Starting PowerShell Automatically which sets the Run key to start PowerShell for the current user on Login with:

 New-ItemProperty HKCU:\Software\Microsoft\Windows\CurrentVersion\Run `
                       -Name  "Windows PowerShell" `
                       -Value "C:\Windows\system32\WindowsPowerShell\v1.0\PowerShell.exe"


I also showed you how to set the PowerShell window size, font, etc in Starting PowerShell Automatically Revisited. And, of course, you can set the PowerShell window colour and syntax highlighting colours as described in Setting Console Colours. Of course, all my $Profile tricks work as well, so check those out.


So, now that we’ve configured the basics of our PowerShell windows, let’s set PowerShell to replace cmd as the default console window. To do that, use the Set-ItemProperty cmdlet to change the WinLogon registry key:

Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' `
                 -Name Shell `
                 -Value 'PowerShell.exe -NoExit'

Viola! Now, when we log on to our Server Core machine, it will automatically open a pair of PowerShell windows, one from WinLogon registry key and one from the Run registry key.

Posted in $Profile, Console, Hyper-V, PowerShell, Windows Server Core | 5 Comments »

5 Responses to “Configuring Windows Server 2016 Core with and for PowerShell”

  1.   Cole Says:

    Hello Mr. Russel.

    I got here after a lot of googling, and I’m stuck on what might be a very simple question. I’m trying Hyper-V as an alternative to VirtualBox for an Ubuntu 16.04 VM, on a Windows 10 Pro host. I am looking for a way to resize the window of the Ubuntu machine, such that the scroll bars are gone. a sort of scaled resizing similar to what VirtualBox can do. I got here because I thought that maybe there was a powershell script I could write to resize the window that Hyper-V displays, I also searched for a registry edit to do the same thing.

    I did find some suggestionns about resizing the display in the VM, but on Hyper-V the Ubuntu machine seems to think that the only display is “Buit-In” and won’t allow a change of resolution. Any ideas would be greatly appreciated.

    •   Charlie Russel Says:

      Cole – For some earlier versions of Ubuntu, the limiting factor was a lack of Virtualization Extensions that needed to be added, but they should be installed by default in 16.04. I don’t run Ubuntu here, but I did a bit of Bingling and found the following on Ben Armstrong’s excellent blog, which I think should solve your problem.
      Yes, it only knows about the Built-In display adapter, but you can control that by editing /etc/default/grub.

  2.   Ryan Oji Says:

    I’ve been trying to use this command but having some trouble with it.

    I’m building a Windows Server 2016 image with Packer to create an instance on AWS. When I run this powershell command in the packer json:

    “Set-DisplayResolution -Width 1920 -Height 1080 -Force”

    I get and error saying that the selected resolution isn’t supported. Do you have any idea what could be going wrong here?

    •   Charlie Russel Says:

      Off hand, I’d have to assume that something with either AWS or Packer is preventing that resolution, since it’s certainly supported on Hyper-V VMs. There are a couple of things that can cause issues, including running in an RDP session as opposed to a console session. For example, see the screen shot here that shows the exact same command failing and then working. The difference is that the first time it was an RDP session at full screen on my 4k monitor, and the second was as a console session. (Note: you’ll have to view the image separately, this template doesn’t allow images in the comments.)

      •   Ryan Oji Says:

        I see, I thought that might be an issue. Like you guessed, I’m am trying to set it through an RDP session so I guess it makes sense that it wouldn’t work if that’s a known issue. Looks like I’ll have to fin another way to do this. Thanks for the response and insight!