1

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?

  • You might try specifying it as a Powershell script. – Davidw Jun 13 at 3:46
  • @Davidw Now I feel a complete fool. When I first set this up it was set as a Powershell script (but failed for some other reason), but over repeated changes along the way that last detail got lost. A quick check just now with it set as a Powershell script and it seems to be working. I'll examine it in more detail in the morning (it's 1:15am here) and update this then – CatchAsCatchCan Jun 13 at 13:16
  • Do you mind if I post that as a full answer? – Davidw Jun 14 at 21:01
  • @Davidw Be my guest 🌝 That part is now working nicely, but the project is now bogged down in other areas. Three steps forward, two steps back! – CatchAsCatchCan Jun 14 at 21:28
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.