I have a Windows Server 2012 R2 (PowerShell 4).
There is a ps1 file with a PowerShell script, which contains among other things the command
I also created a cmd file which should be started via Task Scheduler.
- Everything works as expected when I start the cmd file by double-clicking it.
- Nearly everything works as expected except the reboot when the cmd is started via Windows Task Scheduler.
So I created a ps1 file which only executes
restart-computer and a proper cmd file for testing purposes.
I also tried
powershell.exe -ExecutionPolicy Bypass -File "C:\restart-computer123.ps1"
I also created the scheduled task configured for "Windows Server 2012 R2", with administrative credentials, highest privileges. and saved the password.
There is no error message in the event log or scheduler, but the server isn't rebooting.
What am I missing or doing wrong?