Hi there,
Yes, it is normal for the Process to run in the task scheduler .
If the reply is helpful, please Upvote and Accept it as an answer
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I have a simple Job Running everyday to Restart the server, but the state is always "Running", is this normal ? Just one is completed.
Id Name PSJobTypeName State HasMoreData Location Command
1 Restart-Server PSScheduledJob Running False localhost Restart-Computer -force
2 Restart-Server PSScheduledJob Running False localhost Restart-Computer -force
3 Restart-Server PSScheduledJob Running False localhost Restart-Computer -force
4 Restart-Server PSScheduledJob Completed False localhost Restart-Computer -force
5 Restart-Server PSScheduledJob Running False localhost Restart-Computer -force
6 Restart-Server PSScheduledJob Running False localhost Restart-Computer -force
7 Restart-Server PSScheduledJob Running False localhost Restart-Computer -force
Thank you,
MN
Hi there,
Yes, it is normal for the Process to run in the task scheduler .
If the reply is helpful, please Upvote and Accept it as an answer
Hi,
thank you for your answer, my doubt is the process doesn't finish, it's always in the state of running, only one job in 10 is completed.
You've shown us the status of the jobs, but not the code that the job runs. Can you post the code?
Is there anything in the code that would cause the job to not complete?
Hi,
thank you to take your time :).
the job cannot be more simple than this ....
$T = New-JobTrigger -Daily -At 6:01AM
Register-ScheduledJob -Name Restart-Server -FilePath "C:\restart-vm.ps1" -Trigger $T
My doubt is also quite simple, should not the job be finished (completed), sometimes the job may have problems, but after being executed should go to the state completed.
PS: "Restart-vm -force" is the command
Thank you,
Mario
So your assumption is that the Restart-VM always succeeds? The "-Force" parameter just says not to ask for confirmation before restarting. But a "stuck" VM isn't going to (or can't) accept the command at all.
Can you add a time limit to the scheduled job?