Newbie help - PowerShell script to install fonts

First off, Im a complete Newbie to powershell.

I am working on a project where i need to install a number of fonts from a specific folder, already placed locally on receiving computer. The Font folder has subfolders, containing yet more fonts.

Im trying to automate this process in a script, but no matter what i have tried nothing seems to work. I have full admin rights, and can do it manually - no problem there.

Can some help me get started on this problem… Google Searching gave me a bunch of scripts, but none work for me and i am not well enough versed in powershell to edit them yet.


welcome to So you already searched for it … great. :wink: What have you tried so far and why didn’t it workout for you? Did you try to find something on the PowershellGallery?

This is basically using a vbscript object:

# install fonts

$ssfFonts = 0x14
$fontSourceFolder = ".\fonts"
$Shell = New-Object -ComObject Shell.Application
$SystemFontsFolder = $Shell.Namespace($ssfFonts)
$FontFiles = Get-ChildItem $fontSourceFolder
$SystemFontsPath = $SystemFontsFolder.Self.Path
$rebootFlag = $false

foreach($FontFile in $FontFiles) {
    # $FontFile will be copied to this path:
    $targetPath = Join-Path $SystemFontsPath $FontFile.Name
    # So, see if target exists...
    if(Test-Path $targetPath){
        # font file with the same name already there.
        # delete and replace.
        $rebootFlag = $true
        Remove-Item $targetPath -Force
        Copy-Item $FontFile.FullName $targetPath -Force
        #install the font.

#Follow-up message
    Write-Host "At least one existing font overwritten. A reboot may be necessary."

if ( -not $? ) { exit 1 }

OK, but what script are you running to have this execute on a remote machine?

Invoke-Command ?
PSExec ?

Either should work. Well, the first one requires that PSRemoting be properly enabled and you have admin privs on each target. The second one even allows you to run in the context of the logged on user.

You also say, the font folder has many children. You need to use the recurse to get children.

What errors are you getting, if any at all?