Skip to main content

This worklet will add a TTF or OTF font to your Windows font library. Just upload the .ttf or .otf file to the worklet and set $font to the name of the uploaded font file in the evaluation and remediation.

Evaluation:

$font = "NAME_OF_FONT.ttf"

If (Test-Path "c:\windows\fonts\$($font)") { Exit 0 } else { Exit 1 }

Remediation:

$font = "NAME_OF_FONT.ttf"

    try {
        If (!(Test-Path "c:\windows\fonts\$($font)")) {
            switch (($font -split "\.")[-1]) {
                "TTF" {
                    $fn = "$(($font -split "\.")[0]) (TrueType)"
                    break
                }
                "OTF" {
                    $fn = "$(($font -split "\.")[0]) (OpenType)"
                    break
                }
            }
            Copy-Item $font -Destination "C:\Windows\Fonts\$font" -Force
            New-ItemProperty -Name $fn -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Fonts" -PropertyType string -Value $font
        }
    }
    catch {
        write-warning $_.exception.message
    }

@Tony Thanks! This is awesome!


Hi @Tony,

Thanks for this worklet. I wonder if you have for MacOS version for installing font.

cc: @automoxsupport

Best,
Ulyssis


Thank you,

Tony, I need one more help. I have 20 other fonts, how can I add this to worklet.


Hello,

I need your help with when trying this I am getting WARNING: Cannot bind argument to parameter ‘Name’ because it is null.

$font = “‘EncodeSans-Black.ttf’,‘EncodeSans-Bold.ttf’,‘EncodeSansCondensed-Black.ttf’,‘EncodeSansCondensed-Bold.ttf’,‘EncodeSansCondensed-ExtraBold.ttf’,‘EncodeSansCondensed-ExtraLight.ttf’,‘EncodeSansCondensed-Light.ttf’,‘EncodeSansCondensed-Medium.ttf’
,‘EncodeSansCondensed-Regular.ttf’,‘EncodeSansCondensed-SemiBold.ttf’,‘EncodeSans-ExtraBold.ttf’,‘EncodeSans-ExtraLight.ttf’,‘EncodeSans-Light.ttf’,‘EncodeSans-Medium.ttf’,‘EncodeSans-Regular.ttf’,‘EncodeSans-SemiBold.ttf’,‘EncodeSans-Thin.ttf’”

try {
    If (!(Test-Path "c:\windows\fonts\$($font)")) {
        switch (($font -split "\.")[-1]) {
            "TTF" {
                $fn = "$(($font -split "\.")[0]) (TrueType)"
                break
            }
            "OTF" {
                $fn = "$(($font -split "\.")[0]) (OpenType)"
                break
            }
        }
        Copy-Item $font -Destination "C:\Windows\Fonts\$font" -Force
        New-ItemProperty -name $fn -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Fonts" -PropertyType string -Value $font
    }
}
catch {
    write-warning $_.exception.message
}

if you can help that would be great.


Holy thread resurrection!

Don’t suppose anyone knows how to install multiple fonts in once script?