We have a number of windows 2012 server core systems with powershell setup as the default shell using the following commands:
$RegPath = "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon"
Set-ItemProperty -Confirm -Path $RegPath -Name Shell -Value 'cmd.exe /C start /max PowerShell.exe -noExit'
I've figured out that we can customize the powershell font color with a special powershell script at c:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1. This script gets used by all users.
However now I want to customize the font face and font size (again for all users) that's persistent. I.E. If I log out of the server and log back in I want the settings to be retained. Likewise if I login as administrator, or my own account powershell should look identical - use the same font color, font face and font size.
With Powershell ISE it seems possible to set the font face and font size using:
$psISE.Options.FontName = 'Lucida Sans Console'
$psISE.Options.FontSize = 14
Whats the equivalent for powershell itself though?
Powershell (not the ISE) leverages the "Console Host," which is a slightly more modern update to the ancient MS-DOS command prompt. The Console Host was Microsoft's way of keeping the Command Prompt compatible with modern versions of Windows, but also still compatible with old console apps.
When you launch Powershell.exe, csrss.exe spawns a child process called conhost.exe. This behavior is identical to when you launch Cmd.exe.
But since they had to maintain compatibility with old console apps, they couldn't change the look and feel too much, nor could they go changing and breaking a bunch of internal interfaces.
I'm not going to say that it's impossible, but it is harder than one would think.
There's nothing in
(Get-Host).UI.RawUI
. There's nothing in theSystem.Console
.NET class.You could change the font face and size in the registry by doing something like this:
(edit: underscores not slashes)
There are also a bunch of exports in kernel32.dll that change the font: