Installing Fonts in Windows Using GPO and PowerShell

In this article, we’ll show how to install additional fonts on computers in an Active Directory domain using Group Policy and PowerShell script. This guide was tested on current Windows 10 20H2 and Windows Server 2016/2019 builds.

Contents:

Deploying New Fonts via GPO

If you want to install one or two new fonts, you can do it using the Group Policy. To install a font, copy a *.ttf file to %WindowsDir%Fonts on a client computer and add the new font information to the HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionFonts registry key.

  1. Copy the TTF font file to a shared network folder on your file server (if you have only some new fonts, you can store them in SYSVOL folder on your domain controller);

2. Open the domain Group Policy Management console (gpmc.msc), create a new policy GPO_InstallFonts and link it to the OU with computers;

3. Edit the policy;

4. Create a new rule in Group Policy Preferences to copy a font file from the shared folder to %WindowsDir%Fonts on your client devices. Earlier we showed how to copy a file to computers using GPO. Create a group policy following these instructions. Go to Computer Configuration -> Preferences -> Windows Settings -> Files. Create a policy entry with the parameters below:Source: \woshub.comSYSVOLwoshub.comscriptsFontsRoboto-Black.ttf
Destination:  %WindowsDir%FontsRoboto-Black.ttf

5. Now you need to add the information about your new font to the registry. To make changes to the registry using GPO you can also use GPP (Computer Configuration -> Preferences -> Windows Settings -> Registry);

6. You can specify the font information in the registry manually. However, it is easier to install a font manually on a reference computer and export the font registry settings using a wizard (Computer Configuration -> Preferences -> Windows Settings -> Registry -> New -> Registry Wizard);

7. Use the Registry Browser to go to HKLMSOFTWAREMicrosoftWindows NTCurrentVersionFonts reg key on a remote computer. Find and select the registry item containing the name of the font you want to install;

8. The registry parameter will appear in the GPO editor.

Then update GPO settings on the client computer and make sure that the new font file has been installed. In Windows 10, you can view the list of installed fonts in the Settings -> Personalization -> Fonts.

Install Windows Fonts Using PowerShell Logon Script

It is worth to use the font installation method using GPO described above if you want to install some fonts only. If you want to install a lot of new font files at once, it is better to use a PowerShell script, since it may be tiresome to create special policy options for each font.

The following PowerShell script will install all *.ttf and *.otf font files located in the specified shared folder. Also, the script writes all actions to the log file using the WriteLog function.

function WriteLog
{
Param ([string]$LogString)
$Stamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
$LogMessage = "$Stamp $LogString"
Add-content $LogFile -value $LogMessage
}
$Logfile = "C:Windowsposh_font_install.log"
$SourceFolder = "\woshub.comSYSVOLwoshub.comscriptsFonts"
Add-Type -AssemblyName System.Drawing
$WindowsFonts = [System.Drawing.Text.PrivateFontCollection]::new()
Get-ChildItem -Path $SourceFolder -Include *.ttf, *.otf -Recurse -File |
Copy-Item -Destination "$env:SystemRootFonts" -Force -Confirm:$false -PassThru |
ForEach-Object {
WriteLog "Installing font file $_.name"
$WindowsFonts.AddFontFile($_.fullname)
$RegistryValue = @{
Path = 'HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionFonts'
Name = $WindowsFonts.Families[-1].Name
Value = $_.Fullname
}
$RemoveRegistry = "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionFonts"
Remove-ItemProperty -name $($WindowsFonts.Families[-1].Name) -path $RemoveRegistry
New-ItemProperty @RegistryValue
}

Save the PowerShell script as a PS1 file and run it as a logon script using GPO.

Thus, all font files from the specified folder will be installed in Windows, and the installation date and time will be logged.

If you need to remove all additional fonts in Windows and restore the default ones, follow this guide.




About Seyi

Check Also

How To Change User Password in an RDP Session on Windows

In this article, we’ll show how to change a user password in an RDP session …

Leave a Reply

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