Scheduled task to restart task scheduler

Consider this - you are trying to workaround a critical flaw in the Windows task scheduler service which no one else seams to have, but it causes duplicate processes to be started each day. You don't know why, but restarting the server fixes it, and you find that just restarting the task scheduler service fixes it. So you need to restart task scheduler on a schedule just to work around the problem for now

Simple, get a PowerShell task to run Restart-Service -Name schedule right? Well no, because Restart-Service actually perfoms Stop-Service followed by Start-Service(there isn't an underlying WMI method for restarting a service). But as soon as the schedule service stops, all processes spawned from it also stop. So Start-Service never happens and the task scheduler service is left in a stopped state!

My workaround - start powershell, which spawns a separate independant PowerShell process which does the restarting. So the action of the scheduled task would be:

powershell -NoProfile -Command Start-Process -FilePath powershell -ArgumentList @('-NoProfile', '-Command', 'Restart-Service -name schedule -ErrorAction SilentlyContinue')

All fixed

However, it wasn't a critical flaw in the Windows task scheduler service which caused duplicate processes to be started each day. I just had this:-

I changed the trigger to be a One time trigger and duplicate tasks no longer happen.  So my fault - workaround removed, a lot of time wasted and one I'll not forget