DEV Community

loading...

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

terminalpuncher profile image terminalpuncher.com ・1 min read

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

Discussion (0)

Forem Open with the Forem app