DEV Community

Posted on

Delaying the executing of a PowerShell script until a certain time.

This script waits until 18:30 then run the lines under it to
a) set the Backup service to the Startup type Automatic then
b) Start the service in question

start-sleep ((get-date "18:30pm") - (get-date)).TotalSeconds

Set-Service -Name "Backup Service Controller" -StartupType Automatic; 
Get-Service -Name "Backup Service Controller" | Start-Service
Enter fullscreen mode Exit fullscreen mode

Top comments (0)