Font install
HI all,
I'm trying to install a font to all machines using a script (powershell) in SCCM. i have tried a whole bunch that some work some say they work (they don't show up) i have over 700 machines that need it.
Here is one i have tried:
# Set Font Location
$FontLocation = "\\servername\fontshare\"
# Set Font Reg Key Path
$FontRegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
# Get the list of font files from the Font Location
$FontFiles = Get-ChildItem -Path $FontLocation -Include *.ttf, *.otf, *.fon, *.fnt
-Recurse
# Loop through each font file
foreach ($FontFile in $FontFiles) {
# Copy Font to the Windows Font Directory
$FontDestinationPath = "C:\Windows\Fonts\" + $FontFile.Name
Copy-Item $FontFile.FullName $FontDestinationPath -Force
# Set the Registry Key to indicate the Font has been installed
$RegistryValueData =
"$($FontFile.Name) ($($FontFile.Extension))" # Font name and extension
New-ItemProperty -Path $FontRegPath -Name $FontFile.Name
-Value $RegistryValueData -PropertyType String | Out-Null
Write-Host "Font $($FontFile.Name) installed successfully."
}
Answers (1)
I think your Include statement is a little off. Try this
$FontFolder = "\\NetworkShare\FontsFolder"
$FontItem = Get-Item -Path $FontFolder
$FontList = Get-ChildItem -Path "$FontItem\*" -Include ('*.fon','*.otf','*.ttc','*.ttf')
foreach ($Font in $FontList) {
Write-Host 'Installing font -' $Font.BaseName
Copy-Item $Font "C:\Windows\Fonts"
New-ItemProperty -Name $Font.BaseName -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Fonts" -PropertyType string -Value $Font.name
}