Active Directory – How to Fix Startup PowerShell Script in GPO Not Executing on Windows Server 2016

active-directorygroup-policypowershellwindows-server-2016

I'm trying to get a simple Powershell script to run as a GPO Startup script on my school's workstations. So far I've not had much luck. The script started life as a more involved set of commands intended to determine whether or not an application was installed, and which version, and then install an updated version if required. None of that worked so I've reduced the script to just two lines to see if the script even runs. It doesn't appear to.

The current code:

set-content -Path c:\PSTests\PSTest.log -value "PSTest script run successfully"
exit

This has been installed in a GPO at Computer Configuration/Windows Settings/Scripts (Startup/Shutdown)/Startup

I can run this in the Powershell ISE if I log in, and the text file is created or updated, but using it as a GPO Startup script has no discernible effect.

I ran gpresult /h to determine if the policy is being applied (it is):
enter image description here

I also checked the system logs in Applications & Services Logs/Microsoft/Windows/GroupPolicy/Operationalwhich reports a List of Applicable Group Policy Objects that includes my script GPO. It also reports starting Scripts Extension Processing and lists my GPO, and completing the processing but reports no errors between these two points.

So, it appears that my policy object is being applied, and that my workstation is making some attempt to process it. However, the file it is supposed to create never appears.

I'm clearly missing something – but what?

Best Answer

To run Powershell scripts using Group Policy, use the Powershell Scripts tab of the Group Policy Startup Scripts Properties page. Please note, however, that use of Powershell Scripts requires Windows 7 or Windows Server 2008R2 or above to function.

enter image description here