powershell – Deploying Fonts with PowerShell for Windows 10 Version 1809

powershell

With theĀ 1809 user font support in outlined here and here the method I've used in the past for doing administrative installs of fonts no longer functions, instead installing the font only for specific account the install is run under.

It's a pretty standard PS script, based off one from the powershell gallery.

$ShellAppFontNamespace = 0x14
...
$ShellApp = New-Object -ComObject Shell.Application
$FontsFolder = $ShellApp.NameSpace($ShellAppFontNamespace)
foreach ($Font in $Fonts) {
    Write-Host ('Installing font: {0}' -f $Font.BaseName)
    $FontsFolder.CopyHere($Font.FullName)
    break 
}

Is there some specific flag for copyhere I need to set to indicate this is a system wide command now? As it stands now it looks totally undocumented.

Edit:

I think that this is pointing properly to the C:\Windows\Fonts folder.

PS C:\WINDOWS\system32> $FontsFolder.Self


Application  : System.__ComObject
Parent       : System.__ComObject
Name         : Fonts
Path         : C:\Windows\Fonts
GetLink      :
...

Best Answer

For anyone that's dealing with this issue I found the resolution. Effectively the shell path / variable 0x14 is being overloaded and redirected to the user's profile without a clear way to change this behavior. The CopyHere command as a result fails to save to C:\Windows\Fonts, and is shimmed over to the user's profile directly.

Avoiding the use of shell variable, copying the file by hand and adding the registry key by hand works as it should. I packaged up an updated version on the powershell gallery if anyone needs it.