Skip to content

Instantly share code, notes, and snippets.

@realslacker
Created February 22, 2019 16:47
Show Gist options
  • Save realslacker/879f85347f5dcf726595586ee59d1269 to your computer and use it in GitHub Desktop.
Save realslacker/879f85347f5dcf726595586ee59d1269 to your computer and use it in GitHub Desktop.
Schedule a restart at a specific time
# the same script as a one liner:
# shutdown -r -t ( [math]::Ceiling( ([datetime]"1PM").Subtract((Get-Date)).TotalSeconds )
param(
[Parameter(Mandatory=$true)]
[datetime]
$When
)
$Now = Get-Date
$SecondsToWait = [math]::Ceiling( $When.Subtract( $Now ).TotalSeconds )
shutdown.exe -r -t $SecondsToWait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment