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
}