Powershell Script in GPO Scheduled Task

78 views Asked by At

Windows 2022 Server Domain and Windows Server 2022 client Desktops*.

Trying to run a .ps1 script at logon (per computer) that installs a print driver. I have run the script locally on a client computer, it runs successfully and installs the driver.

It's a relatively simple script as follows:

 #  C287 Driver
Start-Transcript -Path c:\temp\driverslog.txt -Append

$infPath = "\\fsys-00\share\AppInstallFiles\Printer Drivers\Konica Minolta Specific Drivers\C287 - IT5PCL6Winx64_11200EN\IT5PCL6Winx64_11200EN\KOAXPJ__.INF"
pnputil.exe -a $infPath
Add-PrinterDriver -Name  "KONICA MINOLTA C287SeriesPCL"

Stop-Transcript 

My installdriver.ps1 has been added to my domain controller at:

C:\Windows\SYSVOL\sysvol\my-domain-name\scripts

The GPO element I have used is at:

Computer Configuration->Preferences->Control Panel Settings->Scheduled Tasks

The properties of my scheduled task are as follows :

GENERAL
Name= Install Konica Minolta C287 Driver
When running the Task, use the following user account= %LogonDomain%\%LogonUser%
Run only when the user is logged on= yes/ticked/checked/selected
Run only with the highest privileges= yes/ticked/checked/selected
Configured for= Windows Vista or Windows Server 2008
ACTIONS
Start a Program with Details= the path to my installdriver.ps1 

All other parameters are at default

Running GPUPDATE /FORCE and GPRESULT /R confirms that the task runs.

Alas, the driver does not get installed and no c:\temp\driverslog.txt appears (I was hoping this might help diagnose the issue).

I can see from research that I am only one of many 1000s of people having problems running ps1 scripts through GPO and I've tried so many different approaches from so many threads, I've lost count. I am thinking at the moment it is a permissions problem. I have tried setting execution policy at least 3 ways in the script. I have tried running the script as a domain admin account but nothing? I'm trying to avoid copying the script to local machines and running it as, it seems to me, is very untidy and especially so when it comes to editing the script for driver updates.

In terms of diagnosis, it would help to know if errors are recorded in any logs anywhere?

Any guidance greatly appreciated.

0

There are 0 answers