Install fonts with PowerShell

The function Install-Font lets you install fonts using PowerShell. It triggers the Install for all users command, utilizing a technique demonstrated by Stefan Kanthak:

function Install-Font {
	
	[CmdletBinding()]
	param(
		[Parameter( Mandatory, ValueFromPipeline )]
		[System.IO.FileInfo]
		$FontFile,
		
		[switch]
		$WhatIf
	)
	
	begin {
		$shell = New-Object -ComObject 'Shell.Application';
	}
	
	process {
		$file = $(
			if( $FontFile ) {
				$FontFile; # When called with parameter
			} else {
				$_; # When called with pipeline input
			}
		);
		if( $WhatIf ) {
			Write-Host -Message(
				'Installing font "{0}".' -f $file.Name
			);
		} else {
			$shell.NameSpace(
				$file.Directory.FullName
			).ParseName(
				$file.Name
			).Verbs() | ForEach-Object {
				if( $_.Name -eq 'Install for &all users' ) {
					$_.DoIt();
				}
			};
		}
	}
}
Install-Font.ps1

Use this function as follows:

PS C:\> Get-ChildItem -LiteralPath "$env:USERPROFILE\Downloads" -File -Filter *.ttf | Install-Font