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.
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_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts registry key.
- 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);
- Open the domain Group Policy Management console (
gpmc.msc
), create a new policy GPO_InstallFonts and link it to the OU with computers; - Edit the policy;
- 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.com\SYSVOL\woshub.com\scripts\Fonts\Roboto-Black.ttf
Destination:%WindowsDir%\Fonts\Roboto-Black.ttf
- 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);
- 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);
- Use the Registry Browser to go to HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts reg key on a remote computer. Find and select the registry item containing the name of the font you want to install;
- 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:\Windows\posh_font_install.log"
$SourceFolder = "\\woshub.com\SYSVOL\woshub.com\scripts\Fonts"
Add-Type -AssemblyName System.Drawing
$WindowsFonts = [System.Drawing.Text.PrivateFontCollection]::new()
Get-ChildItem -Path $SourceFolder -Include *.ttf, *.otf -Recurse -File |
Copy-Item -Destination "$env:SystemRoot\Fonts" -Force -Confirm:$false -PassThru |
ForEach-Object {
WriteLog "Installing font file $_.name"
$WindowsFonts.AddFontFile($_.fullname)
$RegistryValue = @{
Path = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'
Name = $WindowsFonts.Families[-1].Name
Value = $_.Fullname
}
$RemoveRegistry = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
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.
3 comments
That PS file don’t work
It should be %windir%, not %windowsdir%
%windowsdir% is the group policy preferences %windir%, it depends on when you are wanting it to be processed (somethings will not process the latter and will add it as is). Press F3 when creating a preference for the available variables.