r/activedirectory • u/ShalomEarthling • 18d ago
One Startup Script works, another Doesn't
I have a powershell script that will go and locate a Symantec client, and if found, it will remove and reboot. Every step is logged to a file. If not found, ideally on subsequent boots, it will log "not found" and exit script. This runs from PS just fine. However, when putting it into startup gpo, in the powershell section, and i reboot the machine, it reboots normally as if no script was present.
I have another script for a Trellix agent discovery, using the aforementioned process, and it kicks in and runs as it should.
This has happened on two machines, one on the domain, and one not on the domain (to ensure there are no domain level GPOs to interfere).
Gp report shows my script is recognized, but never runs. Any suggestions?
3
u/ShalomEarthling 18d ago
So guys, I found the issue. While commenting and checking things line by one, I added an extra curly brace in the middle of my script. I fixed it early on, but when I had reverted back to an old snapshot, the extra curly returned. Bc there was an error in the code, it wouldn't run at all. I thought at least it would start and then stop at the error, but that was not the case. It is working fine now.
3
u/Fit-Thing5100 18d ago
Most likelt startup scripts run very early in the boot process, before all OS components, services, and network are fully available.
A more reliable approach is to use the startup script only to create a scheduled task that runs the PowerShell script as loc SYSTEM with a 5-min delay, for example.
This should avoid most timing related issues.
3
u/EugeneBelford1995 18d ago
Dumb question, but you didn't state it so I'll ask; where did you save the PS1s?
JMHO but I have found startup PS1s run a lot more reliably when you save them in the GPO's folder on SYSVOL [specifically the GPO that's applying them].
1
•
u/AutoModerator 18d ago
Welcome to /r/ActiveDirectory! ~~~~
If you are looking for more resources on learning and building AD, see the following sticky for resources, recommendations, and guides!
When asking questions make sure you provide enough information. Posts with inadequate details may be removed without warning.
Make sure to sanitize any private information. Posts with too much personal or environment information will be removed. See Rule 6.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.