Hi,
I got a question. I wanted to install some fonts via Powershell. But I want to check first, if the font is already existing.
Maybe my workaround is not the odd way and also it doesn’t work while the if clause “array is not equal to the file in directory”.
Maybe someone can help me. Thanks a lot.
Kind regards Sam
#Dim Font Network Location (Source)
$NetPath = "\\srv01\Fonts\"
#Dim Font Temporay Location (Temp Source)
$TempPath= "C:\Temp\Fonts\"
#Dim Font Local Location (Local Source)
$FontPath = "C:\Windows\Fonts\"
#Dim Parameters
$Font = 0x14
$objShell = New-Object -ComObject Shell.Application
$objFolder = $objShell.Namespace($Font)
#Create Directory for Temporay Location
New-Item $TempPath -Type Directory -Force
#Copy Fonts from Network Location to Temporary Location
Copy-Item "$NetPath*" $TempPath
#Dim Temporary Fonts Directory
$TempDir = Dir $TempPath
ForEach($File in $TempDir)
{
$Array = @($File.Name)
}
#Dim Local Fonts Directory
$FontDir = Dir $FontPath
ForEach($FileDir in $FontDir)
{
ForEach($FileArr in $Array)
{
If ((Test-Path $File.Name) -ne $FileArr)
{
$objFolder.CopyHere($FileDir.Fullname,0x10)
}
}
}