Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Windows Server Automation with PowerShell Cookbook, Fifth Edition

You're reading from   Windows Server Automation with PowerShell Cookbook, Fifth Edition Powerful ways to automate, manage, and administrate Windows Server 2022 using PowerShell 7.2

Arrow left icon
Product type Paperback
Published in Jan 2023
Publisher Packt
ISBN-13 9781804614235
Length 714 pages
Edition 5th Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Thomas Lee Thomas Lee
Author Profile Icon Thomas Lee
Thomas Lee
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Installing and Configuring PowerShell 7 FREE CHAPTER 2. Managing PowerShell 7 in the Enterprise 3. Exploring .NET 4. Managing Active Directory 5. Managing Networking 6. Implementing Enterprise Security 7. Managing Storage 8. Managing Shared Data 9. Managing Printing 10. Exploring Windows Containers 11. Managing Hyper-V 12. Debugging and Troubleshooting Windows Server 13. Managing Windows Server with Window Management Instrumentation (WMI) 14. Managing Windows Update Services 15. Other Books You May Enjoy
16. Index

Installing the Cascadia Code Font

Fonts, like color schemes in general, are a very personal thing. Some people love the comic sans font, for example, while others loathe it. Some love dark themes, and others don’t. For programming, including PowerShell (with the console, VS Code, and possibly even Notepad), fixed-width fonts are easier to use. But the choice of which font is always a personal preference.

As part of the Visual Studio Code launch, Microsoft also created a new and free font that you can download and use at the PowerShell 7 console and inside VS Code. This recipe shows how you can download the font, install it, and set this font to be the default in VS Code.

This recipe shows how to install the Cascadia Code font, but you can choose many great fonts. See this article on (arguably!) the ten best fonts for use with VS Code: https://toastofcode.com/best-fonts-for-programming-with-vscode/.

And should you want to use a different font for VS Code, you can adapt this recipe to make use of whatever font you wish. Or use the VS Code settings menus to change the font as you may want.

How to do it...

  1. Getting download locations
    $CascadiaRelURL  = 
            'https://github.com/microsoft/cascadia-code/releases'
    $CascadiaRelease = Invoke-WebRequest -Uri $CascadiaRelURL
    $Fileleaf        = ($CascadiaRelease.Links.href |
                         Where-Object { $_ -match $CascadiaFont } |
                           Select-Object -First 1)
    $CascadiaPath   = 'https://github.com' + $FileLeaf
    $CascadiaFile   = 'C:\Foo\CascadiaFontDL.zip'
    
  2. Downloading the Cascadia Code font file archive
    Invoke-WebRequest -Uri $CascadiaPath -OutFile $CascadiaFile
    
  3. Expanding the font archive file
    $FontFolder = 'C:\Foo\CascadiaCode'
    Expand-Archive -Path $CascadiaFile -DestinationPath $FontFolder
    
  4. Installing the Cascadia Code font
    $FontFile = 'c:\Foo\CascadiaCode\ttf\CascadiaCode.ttf'
    $FontShellApp = New-Object -Com Shell.Application
    $FontShellNamespace = $FontShellApp.Namespace(0x14)
    $FontShellNamespace.CopyHere($FontFile, 0x10)
    

How it works...

In step 1, you determine the location of the latest release of the font and set a variable to the location to download the font.

In step 2, you use Invoke-WebRequest to download the font archive. Then in step 3, you use Expand-Archive to expand the archive. Finally, in step 4, you install the Cascadia font.

The steps in this recipe produce no console output – but you can see the change in VS Code after you run these steps.

There’s more...

In step 1, you determine the location of the latest release of the Cascadia Code font on GitHub. The font is heavily used and has been subject to minor updates and improvements over time. This step ensures you get the latest version. The remaining steps expand the downloaded archive and then install the font. Once you complete this recipe, you should observe the font inside VS Code.

In step 2, you download the latest version of the font – but as a ZIP archive, which, in step 3, you expand and then install (in step 4).

You have been reading a chapter from
Windows Server Automation with PowerShell Cookbook, Fifth Edition - Fifth Edition
Published in: Jan 2023
Publisher: Packt
ISBN-13: 9781804614235
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image