-$null = foreach($font in Get-ChildItem -Recurse -Include *.ttf, *.otf) {
- [Session]::AddFontResource($font.FullName)
-}
+$regFontPath = "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
+$fontRegistryPath = "HKCU:$regFontPath"
+$fontFiles = Get-ChildItem -Recurse -Include *.ttf, *.otf
+foreach($font in $fontFiles) {
+ # See https://github.com/PPOSHGROUP/PPoShTools/blob/master/PPoShTools/Public/FileSystem/Add-Font.ps1#L80
+ Add-Type -AssemblyName System.Drawing
+ $objFontCollection = New-Object System.Drawing.Text.PrivateFontCollection
+ $objFontCollection.AddFontFile($font.FullName)
+ $FontName = $objFontCollection.Families.Name