This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hoping someone has some ideas as to what might cause this...
I have a powershell script that is stored in the policy that on start-up should (as below):
- Check if our custom event log has been added to this PC.
- Write an event to this log saying that "Robocopy is starting..."
- Run robocopy to copy a support folder from a dfs share to the local PC.
$logFileExists = Get-EventLog -list | Where-Object {$_.logdisplayname -eq "YYY-Logs"}
if (! $logFileExists) {
New-EventLog -LogName "YYY-Logs" -Source "YYY-Scripts"
}
Write-EventLog -LogName "YYY-Logs" -Source "YYY-Scripts" -EventID 100 -Message "Robocopy Scipt Starting."
robocopy \\YYY.co.uk\Shared\Support$\ C:\Support /MIR
Step 1 seems to be running fine.
Step 2 is definitely running no question but over and over again - in fact it seems to run until a certain time (probably about 5 mins) has elapsed. Cannot really tell though as it is running literally thousands of times before I have logged on and it is hitting the maximum log events on every start-up.
Step 3 is not running.
FYI: If I run the script manually it completes without issue. Have checked the file shares they all have domain computer read access and they have all fully replicated with each other before the script runs.
Have I missed something in the script that says keep restarting the script? Is there a setting in group policy I have overlooked? Is it a symptom of something else or another problem entirely?
Any suggestions are welcome but I'm currently thinking about what hammer would do the most damage to the server. Thanks!
EDIT: Solved
Turns out that having dollar signs and the name of the script were causing the script to call itself recursively, renamed and escaped the $ and it worked fine.
Thanks to all those that provided debugging steps etc.
Subreddit
Post Details
- Posted
- 2 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/activedirec...