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.