Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

How to schedule a one-time reboot via PS oneliner/function?

$
0
0

This is all that I have got.

$action = New-ScheduledTaskAction -Execute 'Powershell.exe' -Argument '-NoProfile -WindowStyle Hidden -command "& {Restart-Computer -Force -wait}"' $trigger = New-ScheduledTaskTrigger -Once -At 3am Register-ScheduledTask -Action $action -Trigger $trigger -TaskName 'ScheduledReboot' 

But this works once, then there is a task called “scheduledReboot” that won’t clear out. Is there a way to make this repeatable?

submitted by /u/trogdor3000
[link] [comments]

The post How to schedule a one-time reboot via PS oneliner/function? appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Trending Articles