Install-Fonts

Install-Fonts

Install Fonts on a Computer with PowerShell

By Michael J. Thomas


It has been a busy week for me and so I have not had much time write a script for this week. I started looking back at some of my old VBScripts and thought it would be fun to write a PowerShell version of Installing Fonts. I created a function called Install-Fonts.  It has two switch options with the current version of it. I have some more ideas I'm going to update this one soon but I'm limited on as of this writing. I hope you all enjoy this one for now.

Select one file with the -File switch Install-Fonts -File "c:\Fonts\FontName.ttf"
Select the whole folder with the -Files switch Install-Fonts -Files "c:\Fonts".




<#
.Synopsis
   Install-Fonts
   Author: Michael J. Thomas
   Created: 07/10/2019
   Updated: 07/10/2019
.DESCRIPTION
   Install Fonts on a computer.
.EXAMPLE
   Install-Fonts -Files "C:\Fonts"
.EXAMPLE
   Install-Fonts -File "C:\Fonts\LeanStatus.ttf"
#>
function Install-Fonts
{
    [CmdletBinding()]
    Param
    (
        [string[]]$Files,
        [string]$File
    )

    $objShell = New-Object -ComObject Shell.Application
    $Fonts = $objShell.NameSpace(20)
    If (!($Files -eq $null)){  Get-ChildItem "$Files\*.ttf" | ForEach-Object {$Fonts.CopyHere($_.FullName)} }
    ElseIf (!($File -eq $null)){ $Fonts.CopyHere($File) }
  
}


Comments

Popular posts from this blog

Add-RemoteDesktopUsers

Invoke-Reprofile

Mike's Profile Cleanup Tool