How to deploy fonts to Windows clients using Intune. (Manual)
Last week I had a customer that wanted to deploy multiple fonts to all his clients. Since there is no default option to deploy fonts to Intune clients, it is time to do some PowerShell magic, in Intune.
How to install fonts on your device?
If you have new fonts, you will normally copy the fonts into the “C:\Windows\Fonts” directory and also register them in the Windows Registry under “HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts”.
We could simply create a single script that copies the TTF or OTF file to Windows Fonts directory, and a second line that registers the Font that has been copied. But how to do that if you have multiple fonts?
Let’s create a script that loops through all files, and then copies them to the Windows Fonts folder and registers them in Windows. From there we will create an Intune package
Manual
STEP 1: Prepare files
In this step we will manually create the files and folders that are required. At the bottom of this manual, you can find a download button to download a prepared zip package.
In this first step we are going to create a folder on your computer with the name IntunePackage (For today we will create it on the C:\ drive)
Now in this create folder, create a new folder named Fonts
In the folder IntunePackage we are going to create 2 PowerShell scripts. First, we are going to create the file that will install the fonts.
install.ps1
$PackageName = "Fonts"
$Version = "1"
$IntuneTMP = "$Env:Programfiles\Intune"
$WorkPath = "$IntuneTMP\Data\Fonts"
#Create logging
Start-Transcript -Path "$IntuneTMP\Log\$PackageName-install.log" -Force
#Create folder and copy fonts
New-Item -ItemType "directory" -Path $WorkPath -Force
Copy-Item -Path ".\Fonts\*" -Destination $WorkPath -Recurse
#Get all fonts
$AllFonts = Get-ChildItem -Path "$WorkPath\*.ttf"
$AllFonts += Get-ChildItem -Path "$WorkPath\*.otf"
#Loop through all fonts, copy them to the Windows folder and register them
foreach($FontFile in $AllFonts){
try{
Copy-Item -Path "$WorkPath\$($FontFile.Name)" -Destination "$env:windir\Fonts" -Force -PassThru -ErrorAction Stop
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" -Name $FontFile.Name -PropertyType String -Value $FontFile.Name -Force
}catch{
Write-Host $_
}
}
#Do some cleanup
Remove-Item $WorkPath -Force -Recurse
#Create a Validation file for intune to pickup
New-Item -Path "$IntuneTMP\Validation\$PackageName" -ItemType "file" -Force -Value $Version
Stop-Transcript
The next step is to create the uninstall file
uninstall.ps1
$PackageName = "Fonts"
$IntuneTMP = "$Env:Programfiles\Intune"
$WorkingPath = "$IntuneTMP\Data\Fonts"
New-Item -ItemType "directory" -Path $WorkingPath -Force
Copy-Item -Path ".\Fonts\*" -Destination $WorkingPath -Recurse
$AllFonts = Get-ChildItem -Path "$WorkingPath\*.ttf"
$AllFonts += Get-ChildItem -Path "$WorkingPath\*.otf"
foreach($FontFile in $AllFonts){
try{
Remove-Item -Path "$WorkingPath\$($FontFile.Name)" -Force
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" -Name $FontFile.Name -Force
}catch{
Write-Host $_
}
}
Remove-Item $WorkingPath -Force -Recurse
Remove-Item -Path "$IntuneTMP\Validation\$PackageName" -ItemType "file" -Force -Value $Version
The last files that need to be copied are your fonts. Copy them to the c:\IntunePackage\Fonts folder, and go to step 2.
STEP 2: Prepare Intune Package
Before you can add a Win32 app to Microsoft Intune, you must prepare the app by using the Microsoft Win32 Content Prep Tool. You can download this file from GitHub: https://github.com/microsoft/Microsoft-Win32-Content-Prep-Tool/raw/master/IntuneWinAppUtil.exe
Now open a PowerShell prompt as Administrator, and run the IntuneWinAppUtil.exe
Fill in the requested parameters
In the output folder you can now find a file with the name install.intunewin
You are going to need it in step 3.
Now create a new file that is required to check the installation on your client. In the same folder as the intune package, create the following file:
check.ps1
$PackageName = "Fonts"
$Version = "1"
$ProgramVersion_current = Get-Content -Path "$Env:Programfiles\Intune\Validation\$PackageName"
if($ProgramVersion_current -eq $Version){
Write-Host "Found it!"
}
STEP 3: Create the Intune Win32 app
Now go to the Intune portal: https://endpoint.microsoft.com/
Go to Apps -> Windows
Click Add, and select Windows app (Win32) and click Select
In the next window you will be able to select your intune package file. Click Next when ready
Fill in all the fields that will help make it look nice.
In the next field we will need to fill in the install and uninstall commands. Use the following commands, and click Next when ready.
Install command: | %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -command .\install.ps1 |
Uninstall command: | %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -command .\uninstall.ps1 |
Select the operating system, both x86 and x64 will work, and select a minimum operating system version. Click Next when ready
As a detection rule we are going to upload the check.ps1 script that we created in step 2.
We don’t have any Dependencies of supersedence, so click Next twice.
Now select the group that we are going to assign this font to be deployed. In this example I’ve created a group name 2azure – fonts with just my user account.
Now do a final review, and click Create. Give it a few hours, and check back to review the results in step 4.
STEP 4: Review
From the app overview you can now review the current status.
Downloads
For your convienience I’ve created a zip file with all scripts and the folders pre created.
Very Helpful , thanks for the tutorial. Always very nice to read all your blogs and quickwins.
Hi Corr. Thank you for the tutorial. We tried deploying custom fonts using the mentioned steps and while testing the same, the deployment fails with, ‘the application was not detected after installation completed successfully (0x87d1041c)’ error.
Could you help with how to overcome this?
Hi Nitin,
I am wondering, what did you use as a testing method?