> ## Content Index
> Fetch the complete content index at: https://www.kollr.at/llms.txt
> Use this file to discover other available public pages before exploring further.

# Schedule a One-Time Server Reboot with PowerShell
- URL: https://www.kollr.at/schedule-a-one-time-server-reboot-with-powershell/
- Published: 2026-07-02T14:35:26.000Z
- Updated: 2026-07-02T14:35:26.000Z
- Description: Sometimes a server needs to be restarted outside business hours, but you do not want to wait until the planned reboot window. A simple PowerShell script can create or update a one-time Scheduled Task for this.
- Author: Georg Koller
- Tags: PowerShell, Snippets, Windows Server

### reboot.ps1

```powershell
# general settings
$TaskName = "Server.OneTime.Reboot"
$TaskPath = "\"
$Description = "Reboot computer automatically one time"

$trigger = New-ScheduledTaskTrigger -Once -At "6/1/2023 04:00:00 AM"

$action = New-ScheduledTaskAction `
    -Execute "powershell.exe" `
    -Argument "Restart-Computer -Force"

$principal = New-ScheduledTaskPrincipal `
    -UserId "SYSTEM" `
    -LogonType ServiceAccount `
    -RunLevel Highest

$settings = New-ScheduledTaskSettingsSet

$exists = Get-ScheduledTask `
    -TaskPath $TaskPath `
    -TaskName $TaskName `
    -ErrorAction SilentlyContinue

if ($exists) {
    Set-ScheduledTask `
        -TaskPath $TaskPath `
        -TaskName $TaskName `
        -Action $action `
        -Principal $principal `
        -Trigger $trigger `
        -Settings $settings | Out-Null

    Write-Host "Updated Task $TaskName"
}
else {
    $task = New-ScheduledTask `
        -Action $action `
        -Principal $principal `
        -Trigger $trigger `
        -Settings $settings `
        -Description $Description

    Register-ScheduledTask `
        -TaskPath $TaskPath `
        -TaskName $TaskName `
        -InputObject $task | Out-Null

    Write-Host "Created Task $TaskName"
}

```

## How it works

The script creates a Scheduled Task named `Server.OneTime.Reboot`. The task runs only once at the configured time and executes:

```powershell
Restart-Computer -Force

```

The task runs as `SYSTEM` with the highest privileges, so no separate service account or stored credentials are required.

If the task already exists, it is updated instead of being created again. This makes the script safe to run multiple times when the reboot time changes.

## Adjust the reboot time

Change the trigger to the required maintenance window:

```powershell
$trigger = New-ScheduledTaskTrigger -Once -At "12/3/2025 04:00:00 AM"

```

## Verify the task

```powershell
Get-ScheduledTask -TaskName "Server.OneTime.Reboot"

```

This is a useful small admin script for planned reboots, maintenance windows, and remote server preparation.