Newbie help - PowerShell script to install fonts

Welcome Forums General PowerShell Q&A Newbie help - PowerShell script to install fonts

This topic contains 3 replies, has 4 voices, and was last updated by

3 months ago.

  • Author
  • #145983

    Topics: 1
    Replies: 0
    Points: 13
    Rank: Member

    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.

  • #146018

    Topics: 1
    Replies: 1375
    Points: 1,889
    Helping Hand
    Rank: Community Hero


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

  • #146120

    Topics: 22
    Replies: 626
    Points: 1,318
    Helping Hand
    Rank: Community Hero

    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 }
  • #146243

    Topics: 2
    Replies: 969
    Points: 1,789
    Helping Hand
    Rank: Community Hero

    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?

The topic ‘Newbie help - PowerShell script to install fonts’ is closed to new replies.