$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" $Parameters = @{ Uri = "https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest" UseBasicParsing = $true } $FiraCodeLatestRelease = ((Invoke-RestMethod @Parameters).assets | Where-Object -FilterScript {$_.name -eq "FiraCode.zip"}).browser_download_url $Parameters = @{ Uri = $FiraCodeLatestRelease OutFile = "$DownloadsFolder\FiraCode.zip" UseBasicParsing = $true Verbose = $true } Invoke-WebRequest @Parameters $Parameters = @{ Path = "$DownloadsFolder\FiraCode.zip" DestinationPath = "$DownloadsFolder\FiraCode" Force = $true Verbose = $true } Expand-Archive @Parameters Get-ChildItem -Path "$DownloadsFolder\FiraCode" -Recurse -Force | Unblock-File # Installing fonts # https://docs.microsoft.com/en-us/windows/desktop/api/Shldisp/ne-shldisp-shellspecialfolderconstants # https://docs.microsoft.com/en-us/windows/win32/shell/folder-copyhere $ssfFONTS = 20 # https://docs.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-shfileopstructa $FOF_SILENT = 4 $FOF_NOCONFIRMATION = 16 $FOF_NOERRORUI = 1024 $CopyOptions = $FOF_SILENT + $FOF_NOCONFIRMATION + $FOF_NOERRORUI $CopyOptions = '0x{0:x}' -f $CopyOptions $Fonts = Get-ChildItem -Path "$DownloadsFolder\FiraCode" | Where-Object -FilterScript {($_.Name -match "Fira") -and ($_.Name -match "Compatible")} foreach ($Font in $Fonts) { (New-Object -ComObject Shell.Application).NameSpace($ssfFONTS).CopyHere($Font.FullName, $CopyOptions) }