# Installing Font using Admin Account to install for Local Users

**URL:** <https://forums.powershell.org/t/installing-font-using-admin-account-to-install-for-local-users/15634>\
**Category:** PowerShell Help\
**Created:** [February 12, 2021, 5:54am UTC](https://forums.powershell.org/t/installing-font-using-admin-account-to-install-for-local-users/15634 "2021-02-12T05:54:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisdewey1991](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/chrisdewey1991/32/1656_2.png) [@chrisdewey1991](https://forums.powershell.org/u/chrisdewey1991)\
**Post date:** [February 12, 2021, 5:54am UTC](https://forums.powershell.org/t/installing-font-using-admin-account-to-install-for-local-users/15634/1 "2021-02-12T05:54:55Z")

</div>

Hi, I have created a script from connecting scripts together and adapting them. I use 1 script to install Fonts this works well when running on the local computer but I would like to run in through a Device Manager that manages all my computers. However when the script runs its running as admin.

I think its because in a bit of my script is has

> C:\Users\$username\AppData\Local\Microsoft\Windows\Fonts

Is there any PowerShell script that will generate a list of users and replace $username with that so that when this script runs it will do it for all the users on that computer?

&nbsp;

Full Script Below

$FONTS = 0x14  
$FontItem = Get-Item -Path $Path  
$FontList = Get-ChildItem -Path “$FontItem\*” -Include (‘_.fon’,'_.otf’,‘_.ttc’,'_.ttf’)  
$objShell = New-Object -ComObject Shell.Application  
$objFolder = $objShell.Namespace($FONTS)  
$Fontdir = dir $Path  
$username = $env:UserName  
$Path=“C:\Source\Font\_Post\_Grotest”

foreach($File in $FontList) {  
if(!($file.name -match “pfb$”))  
{  
$try = $true  
$installedFonts = @(Get-ChildItem C:\Users$username\AppData\Local\Microsoft\Windows\Fonts | Where-Object {$\_.PSIsContainer -eq $false} | Select-Object basename)  
$name = $File.baseName

foreach($font in $installedFonts)  
{  
$font = $font -replace “_", “”  
$name = $name -replace "_”, “”  
if($font -match $name)  
{  
$try = $false  
}  
}  
if($try)  
{  
$objFolder.CopyHere($File.fullname)  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![ralphmwr](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/ralphmwr/32/1064_2.png) [@ralphmwr](https://forums.powershell.org/u/ralphmwr)\
**Post date:** [February 12, 2021, 6:22am UTC](https://forums.powershell.org/t/installing-font-using-admin-account-to-install-for-local-users/15634/2 "2021-02-12T06:22:54Z")

</div>

Get-Childitem will take wildcards in the path parameter. See Get-Help Get-ChildItem:

```
-Path <System.String[]>
        Specifies a path to one or more locations. Wildcards are accepted. The default location is the current directory ('.').

        Required? false
        Position? 0
        Default value Current directory
        Accept pipeline input? True (ByPropertyName, ByValue)
        Accept wildcard characters? true
```

With that you can just do this:

```
Get-ChildItem -Path C:\Users\*\AppData\Local\Microsoft\Windows\Fonts -File
```

Also if you have version PS version 5.1 you can just use the -File switch parameter to only return files. That will save you the pipe overhead to Where-Object.

&nbsp;

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:27pm UTC](https://forums.powershell.org/t/installing-font-using-admin-account-to-install-for-local-users/15634/3 "2024-05-16T20:27:51Z")

</div>


