Configuring Windows Server 2016 Core with and for PowerShell

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 1024x768. 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 1600x900 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.

2 Responses to Configuring Windows Server 2016 Core with and for PowerShell

  • 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.

Leave a Reply

Your email address will not be published. Required fields are marked *