PowerShell doesn’t come with a built-in cmdlet for setting the font size. However, after you import the SetConsoleFont module, you can easily change the font size with the Set-ConsoleFont cmdlet.
Latest posts by Michael Pietroforte (see all)

You might wonder why anyone would want to change the font size of the PowerShell console with a cmdlet. If you don’t like the default font, you can easily change it through the Windows PowerShell properties. You just have to click the PowerShell icon in the upper left corner of the console and then select “Properties.”

PowerShell console - Properties

PowerShell console - Properties

PowerShell Properties - Font size

PowerShell Properties - Font size

This method has two downsides. Number one is that it involves click-click, which any real PowerShell geek will avoid at all costs. Number two is that, it is difficult to automate changing the font size this way, for instance, if you intend to deploy a PowerShell profile in your network.

This is where the SetConsoleFont module comes in. Before you can use the Set-ConsoleFont cmdlet, you have to import the module. First, copy the module to a local editor. Note that when I copied the text, the last line had an unwanted line break. Make sure that the last line of the module looks like this:

Export-ModuleMember -Variable _DefaultFont, _hConsoleScreen -Function Set-ConsoleFont, Get-ConsoleFontInfo

Next, you have to store the file in your module folder. With $env:PSModulePath on a PowerShell console, you can get a list of your module folders. For instance, you can store the SetConsoleFont module in the PowerShell module folder in the Documents directory using the file name SetConsoleFont.psm1, like this:

%USERPROFILE%\Documents\WindowsPowerShell\Modules\SetConsoleFont\SetConsoleFont.psm1

Then, you can import the module with:

Import-Module SetConsoleFont

You can now get a list of the available fonts and their dimensions with:

Get-ConsoleFontInfo | Format-Table -AutoSize

Get-ConsoleFontInfo

Get-ConsoleFontInfo

To set a font size, you have to choose a number from the nFont column:

Set-ConsoleFont 8

To change your font size to the default, you can run Set-ConsoleFont without an argument.

25 Comments
  1. Arthur Jones 6 years ago

    Hi I tried this but got an error, all in red:

    C:\Users\Adrian\Documents\WindowsPowerShell\Modules\SetConsoleFont>powershell -command “&{set-executionpolicy remotesigned; Import-M
    odule SetConsoleFont; Get-ConsoleFontInfo | Format-Table -AutoSize}”
    Set-ExecutionPolicy : Access to the registry key ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell’
    is denied.
    At line:1 char:22
    + &{set-executionpolicy <<<<  remotesigned; Import-Module SetConsoleFont; Get-ConsoleFontInfo | Format-Table -AutoSize}
    + CategoryInfo          : NotSpecified: (:) [Set-ExecutionPolicy], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand

    Import-Module : File C:\Users\Adrian\Documents\WindowsPowerShell\Modules\SetConsoleFont\SetConsoleFont.psm1 cannot be loaded becaus
    e the execution of scripts is disabled on this system. Please see “get-help about_signing” for more details.
    At line:1 char:50
    + &{set-executionpolicy remotesigned; Import-Module <<<<  SetConsoleFont; Get-ConsoleFontInfo | Format-Table -AutoSize}
    + CategoryInfo          : NotSpecified: (:) [Import-Module], PSSecurityException
    + FullyQualifiedErrorId : RuntimeException,Microsoft.PowerShell.Commands.ImportModuleCommand

    The term ‘Get-ConsoleFontInfo’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spe
    lling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:86
    + &{set-executionpolicy remotesigned; Import-Module SetConsoleFont; Get-ConsoleFontInfo <<<<  | Format-Table -AutoSize}
    + CategoryInfo          : ObjectNotFound: (Get-ConsoleFontInfo:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

  2. Arthur Jones 6 years ago

    It is the first line in my printout above:

    C:\Users\Adrian\Documents\WindowsPowerShell\Modules\SetConsoleFont>powershell -command “&{set-executionpolicy remotesigned; Import-Module SetConsoleFont; Get-ConsoleFontInfo | Format-Table -AutoSize}”

  3. Arthur Jones 6 years ago

    Yes, but this happens:

    C:\Users\Adrian\Documents\WindowsPowerShell\Modules\SetConsoleFont>powershell -command Import-Module SetConsoleFont
    Import-Module : File C:\Users\Adrian\Documents\WindowsPowerShell\Modules\SetConsoleFont\SetConsoleFont.psm1 cannot be loaded becaus
    e the execution of scripts is disabled on this system. Please see “get-help about_signing” for more details.
    At line:1 char:14
    + Import-Module <<<<  SetConsoleFont
    + CategoryInfo          : NotSpecified: (:) [Import-Module], PSSecurityException
    + FullyQualifiedErrorId : RuntimeException,Microsoft.PowerShell.Commands.ImportModuleCommand

  4. Arthur Jones 6 years ago

    I managed to change execution policy under Administrator:

    powershell -command set-executionpolicy remotesigned

    However: powershell -command Import-Module SetConsoleFont

    gives a lot of red messages which start:

    Add-Type : (0) : Warning as Error: Invalid search path ‘C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.3.207\windows\tbb\lib\ia32\vc_mt’ specified in ‘LIB environment variable’ — ‘The system cannot find the path specified. ‘
    (1) : using System;
    At C:\Users\Adrian\Documents\WindowsPowerShell\Modules\SetConsoleFont\SetConsoleFont.psm1:60 char:9
    + Add-Type <<<<  -MemberDefinition $source  -Name Console -Namespace Win32API
    + CategoryInfo          : InvalidData: (error CS1668: W…th specified. ‘:CompilerError) [Add-Type], Exception
    + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand

    • Author

      Don’t use “powershell -command…” Instead open a PowerShell console and follow the instructions in the article.

  5. Arthur Jones 6 years ago

    I implemented what you say in a PowerShell console and it all works fine thanks.  However it doesn’t look practical for me for the following reasons:

    I wish to change the font of new window seamlessly from a batch file, which will be run by users of the software.  They may not have Administrator access and so cannot execute “set-executionpolicy remotesigned” which I needed to do to get it working.

    Also this has to be done in a DOS batch file, so opening up a powershell window is not an option.  You mentioned that it only work in a PowerShell window and not with the DOS “powershell -command” option.

    Do you have any idea how I could get around the above limitations?

    • Author

      Using a batch script to do PowerShell stuff is perhaps a bit uncommon. Why would you want to do that?

      I think your main problem is the execution policy. Maybe this helps. After you solved this problem, you should be able to configure the font in a PowerShell script.

  6. Arthur Jones 6 years ago

    I’d rather the batch file did everything.  But changing the font appears to be something it cannot easily do, so I looked online foe a solution and came up with this powershell solution, so I thought I’d try it.  This is where I’m at now:

    D:\>powershell.exe -executionpolicy bypass -command “${Import-Module C:\Users\Adrian\Documents\WindowsPowerShell\Modules\SetConsoleFont\SetConsoleFont.psm1 -Verbose}”

    D:\>powershell -command “&{Get-ConsoleFontInfo | Format-Table -AutoSize}”
    The term ‘Get-ConsoleFontInfo’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:22
    + &{Get-ConsoleFontInfo <<<<  | Format-Table -AutoSize}
    + CategoryInfo          : ObjectNotFound: (Get-ConsoleFontInfo:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    D:\>dir C:\Users\Adrian\Documents\WindowsPowerShell\Modules\SetConsoleFont\SetConsoleFont.psm1
    Volume in drive C is OS

    Directory of C:\Users\Adrian\Documents\WindowsPowerShell\Modules\SetConsoleFont

    03/22/2017  03:28 PM             3,546 SetConsoleFont.psm1
    1 File(s)          3,546 bytes

  7. Arthur Jones 6 years ago

    I tried it all in one command:

    powershell.exe -executionpolicy bypass -command “${Import-Module C:\Users\Adrian\Documents\WindowsPowerShell\Modules\SetConso‌​‌​leFont\SetConsoleF‌​on‌​t.psm1 -Verbose ; Get-ConsoleFontInfo | Set-ConsoleFont 8}”

    but the font in the window stayed exactly the same. I tried a few different font numbers.

    In fact,

    D:\powershell.exe -executionpolicy bypass -command “${Import-Module C:\Users\Adrian\Documents\WindowsPowerShell\Modules\SetConso‌​leFont\SetConsoleFon‌​t.psm1 -Verbose ; Get-ConsoleFontInfo | Format-Table -AutoSize}”

    doesn’t show any table either.

  8. Arthur Jones 6 years ago

    Michael, can I assume that this is not possible from a command prompt, or am I missing something?

  9. Arthur Jones 6 years ago

    Mainly because I’ve used batch files for ages and know the syntax and have many tools to do funky things.

    • Author

      Yeah, that is what I thought. You are trying to pull a Ferrari using a bicycle just because are used to ride a bike. Try driving the Ferrari. You will see that you cannot only get things much faster, you can also go much farer. And guess what, it is also more fun. My advice is this: Never ever write a batch script again.

  10. Tim Dunn 6 years ago

    I’m not getting any font info on PSH (not Run As Administrator) on Windows 10 Enterprise.

    After setting a breakpoint in Get-ConsoleFontInfo, I run GetNumberOfConsoleFonts and get 0 (zero) as a return value.

  11. Author

    Maybe you didn’t load the module? What do you see on the console after entering Get-ConsoleFontInfo?

  12. morton 6 years ago

    I ran the import-module without any error feedback in win 10 ENT.
    but when i load the module and input Get-ConsoleFontInfo it returned nothing
    and
    Set-ConsoleFont 10
    return

    Illegal font index number. Check correct number using ‘Get-ConsoleFontInfo’.
    At C:\Users\mortonch\Documents\WindowsPowerShell\Modules\SetConsoleFont\SetConsoleFont.psm1:109 char:21
    + … !$flag ) { throw “Illegal font index number. Check correct number us …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OperationStopped: (Illegal font in…nsoleFontInfo’.:String) [], RuntimeException
    + FullyQualifiedErrorId : Illegal font index number. Check correct number using ‘Get-ConsoleFontInfo’.

  13. Alex Rune Berg 5 years ago

    It didn’t work for me either, also empty list of fonts. I can live without, I just wanted to mention it.

    I’m using execution polity remoteSigned, no errors. I even removed my custom powershell profile.

    PS C:\Users\Alex> Import-Module SetConsoleFont
    PS C:\Users\Alex> Get-ConsoleFontInfo
    PS C:\Users\Alex>

    There’s no output from either command. I’m on a freshly installed (2weeks old) win 10, build 1709.

    Best Alex

  14. Author

    It seems the module no longer works. Just tried it on Windows 10.

  15. JP 5 years ago

    I also tried it on windows 10. doesn’t work.. guess it’s back to clicky clicky!

  16. Marco Lackovic 4 years ago

    @Michael do you know any way to set font size and color in PowerShell Core 6?

    • Author

      I never tried it but I somehow doubt that this can work (reliably). PowerShell Core needs to be cross platform compatible. Every terminal has its own fonts and in some terminals you can't change the font size programmatically.  If you are on Windows, I suppose the font size is stored in the Registry and you could use PowerShell to change the settings.

  17. Sylvain 3 years ago

    I tried it with PowerShell Core / Windows 10, Get-ConsoleFontInfo doesn't seem to return anything :'(

  18. ron backal 1 year ago

    thank you great article

Leave a reply to Arthur Jones Click here to cancel the reply

Please enclose code in pre tags

Your email address will not be published.

*

© 4sysops 2006 - 2023

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account