Score:0

Event 1202 when trying to run a scheduled task GPO under NT Authority\System

cv flag

I'm trying to get a barcode font installed on machines for a enterprise application. The GPO is being served from a Windows Server 2019 Standard version 1809 OS build 17763.4252 server. The GPO in question uses computer preferences -> Scheduled Tasks to immediately run a script. Shown below.

#$fonts = (New-Object -ComObject Shell.Application).Namespace(0x14)
$Path = Test-Path \\DC\netlogon\font\
if($Path -eq $true)
{
Write-EventLog -Source Application -LogName Application -EventId 301 -EntryType Information -Message "The Network Path is True" 
$fontFolder = "\\DC\NETLOGON\Font\ "
$fontItem = Get-Item -Path $fontFolder
$fontList = Get-ChildItem -Path "$fontItem\*" -Include ('*.fon','*.otf','*.ttc','*.ttf')
$RegPath =(Test-Path 'HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Fonts')
$objFont = New-Object System.Drawing.Text.PrivateFontCollection

}
foreach ($font in $fontList) 
    {
     $objFont.AddFontFile($font.FullName)
     $objTitle = $objFont.Families[-1].Name 
     $fontName = $font.Name
     $objExtension = switch ($font.Extension)
        {
            .TTF {"(True Type Font)"}
            .OTF {"(Open Type Font)"}
            Default {
            Write-EventLog -Source Application -LogName Application -EventId 305 -EntryType Information -Message "Font Extension not Found"
            }
         }  
     $FontTitle = $objTitle + " " + $objExtension
     if (-not(Test-Path -Path "C:\Windows\fonts\$fontName" )) {
        Write-EventLog -Source Application -LogName Application -EventId 302 -EntryType Information -Message "Font not Found, Installing font."
        echo $fontName

        reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v $FontTitle /t REG_SZ /d DWBAR39.TTF /f
        cp $font C:\Windows\Fonts 
        
        if (Test-Path -Path "C:\windows\fonts\$fontName")
            {
            Write-EventLog -Source Application -LogName Application -EventId 306 -EntryType Information -Message "Font Installed."
         }   
        
    }
    
    elseif (Test-Path -Path "C:\Windows\fonts\$fontName"){
    Write-EventLog -Source Application -LogName Application -EventId 303 -EntryType Information -Message "Font Already Installed in C:\windows\fonts\"
    }
   }
   

The Script works well locally. I can run it and it works no problem. Whenever I refresh the group policy, I get Event 1202,SceCLI

0x5 : Access is denied. Advanced help for this problem is available on https://support.microsoft.com. Query for "troubleshooting 1202 events".

Currently it's running as so in the GPO.

Name C - Font Installer
Author 'Me'
Description Installs fonts. Run only when user is logged on S4U
UserId NT AUTHORITY\System
Run with highest privileges HighestAvailable Hidden Yes
Configure for 1.2
Enabled Yes

Program/script C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Arguments -ExecutionPolicy Bypass -Command '& \DC\netlogon\add-Font.ps1' Start in C:\Windows\System32\WindowsPowerShell

Stop if the computer ceases to be idle Yes
Restart if the idle state resumes No
Start the task only if the computer is on AC power Yes
Stop if the computer switches to battery power No
Allow task to be run on demand Yes
Run task as soon as possible after a scheduled start is missed Yes Stop task if it runs longer than 3 days force it to stop Yes If the running task does not end when requested, If the task is not scheduled to run again, delete it after Immediately If the task is already running, then the following rule applies StopExisting

Going down the Permissions angle. I found by using PSEXEC64.exe -sid powershell. And running out the dir $font | %{$fonts.CopyHere($_.FullName)} There isn't any output.

This site https://eddiejackson.net/wp/?p=16137 Helps with why that may be. Seems the 0x14 shell variable is being overloaded and redirects to the user profile. Which I've seen happen when I ran the script locally.

*After additions to the script I still get the SceCLI errors, It doesn't appear the script even runs, because I do not get any of the event logging that I added. How/Why? I'm using the SYSTEM account to perform these actions.

I disabled windows firewall for domain scope, and now I no longer receive the SceCLI error. Still nothing applies.

Any help at all would be amazing.

thank you.

cn flag
You need to add logging to your script so that it will record where the error occurs.
Liam Chaney avatar
cv flag
It's not the script. I've isolated the cause by also disabling the script and trying again via this method https://4sysops.com/archives/install-fonts-in-windows-10-or-windows-11-with-group-policy/ Creating a registry and copying the fonts. I still get the SceCLI message and now I get a The computer 'Fonts' preference item in the 'C - Font Installer {592B0841-56DD-4D91-80DD-CBEF90ED4218}' Group Policy Object did not apply because it failed with error code '0x80070005 Access is denied.' This error was suppressed. Event 4098, Group Policy Files
Score:0
cv flag

It turned out to be an issue with the script. Powershell ISE interpreted everything properly but when processed as a GPO it was not. The Line

$fontFolder = "\\DC\NETLOGON\Font\" 

Broke the quotations because the \ acted as an ignore character. After I took that backslash away it started working properly. @GregAskew You can say I told you so.

Thanks, WC.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.