Syncro Reboot command Script

Is the default Syncro reboot command available to use as a script? I like the simple design and functionality. I’m surprised to see there isn’t a default reboot available to be scheduled on assets.

That’s a special internal script so it’s not. That said, you can easily create one. Reboots are basically one liners in batch and powershell.

BATCH

shutdown –r

POWERSHELL

Restart-Computer

Just note that in many cases you may want to add a delay to the reboot command, as instant reboots might occur before the script has the chance to send the results back to the web to show completion.

Thanks @Andy, I built one of each of those, gotta fancy em up now :wink:

Yeah no problem at all :).

You may want to use /g for a ‘gentle’ restart instead of /r (reopens apps) and /f for forcing if you mean business.

Thanks, I wasn’t aware of /g. I’ll have to test that on some Dentrix systems to see if it will restart them instead of /f.

You can use /f still, it just forces apps to close even if they don’t want to. Which can potentially lose data but otherwise the system will just wait for the user to close the app gracefully/save their files

Our solution was to use PowerShell to create a scheduled task–much more flexible.

ScheduledTasks Module | Microsoft Docs

@curtis3, would you willing to share that Powershell Schecduled Task with someone who struggles with Powershell? I’ve been working on this for a while without success.

Here is one I use to Schedule a Syncro service restart task.

if ($mode -ne "install" -And $mode -ne "reinstall" -And $mode -ne "uninstall") { $mode = "install" }

## Uninstall - Always attempt to remove the task. We don't ever want more than one.
if ($(Get-ScheduledTask -TaskName "SyncroRestart" -ErrorAction SilentlyContinue).TaskName -eq "SyncroRestart") {
    Unregister-ScheduledTask -TaskName "SyncroRestart" -Confirm:$False
}

## Install/Reinstall
if ($mode -eq 'install' -Or $mode -eq 'reinstall' ){
    $action = New-ScheduledTaskAction -Execute 'Powershell.exe' -Argument '-command "Restart-Service -Name Syncro -Force; Restart-Service -Name SyncroLive -Force"'
    $trigger =  New-ScheduledTaskTrigger -Daily -At 2am
    Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "SyncroRestart" -Description "Daily Restart the Syncro Services" -RunLevel "Highest" -Force -User "System"
}

Hi Roger:

We’ve essentially done what Jeff posted, except I always unregister existing scheduled task each run so the Syncro script is idempotent.

Configuring the task:

# task configurations
$ScheduledTask = @{
    'TaskName' = 'Reboot Schedule';
    'Description' = 'Automated, scheduled reboots';
    'Action' = (New-ScheduledTaskAction -Execute 'shutdown.exe' -Argument '/r /t 0');
    'Principal' = (New-ScheduledTaskPrincipal -UserId 'LOCALSERVICE' -LogonType ServiceAccount -RunLevel Highest);
}

Then, I would just refer to Jeff’s script for setting up trigger. To place the trigger in the above hash:

$ScheduledTask['Trigger'] = New-ScheduledTaskTrigger -Weekly -DaysOfWeek ($DaysPerWeek.Split(',')) -At $TimeOfDay -RandomDelay (New-TimeSpan -Hours 1)

I made $DaysPerWeek and $TimeOfDay Syncro runtime variables.

At the end, just register the task using the hash:

Register-ScheduledTask @ScheduledTask

You can also place your tasks within folders, I believe: $TaskName = 'My Folder\Task Name'