In this post, we will share a PowerShell script that automates the process of rebooting servers across your network. Regular maintenance and reboots may be necessary to apply updates and maintain system performance. This script allows administrators to efficiently reboot specified servers, or even groups of servers, with minimal manual intervention, ensuring that your systems remain up-to-date and running smoothly. Here is the PowerShell script for automating server reboots:
powershell
# Define the list of servers to reboot
$servers = @("Server1", "Server2", "Server3") # Replace with your server names
# Define a message for confirmation before reboot
$confirmationMessage = "This will restart the following servers: $($servers -join ', '). Do you wish to continue? (Y/N)"
# Confirm before proceeding
if ((Read-Host $confirmationMessage) -eq 'Y') {
foreach ($server in $servers) {
try {
Restart-Computer -ComputerName $server -Force -ErrorAction Stop
Write-Host "Successfully rebooted $server" -ForegroundColor Green
} catch {
Write-Host "Failed to reboot $server: $_" -ForegroundColor Red
}
}
} else {
Write-Host "Reboot operation cancelled."
}Run it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
More in System Administration
Generate a Random Password with PowerShell
2026-08-17Get the Public IP Address with PowerShell
2026-08-17Send a Wake-on-LAN Magic Packet with PowerShell
2026-08-17Force a Windows Shutdown with PowerShell
2026-08-17Download and Extract Files with BITS in PowerShell
2026-08-17Check Linux Uptime and Disk Usage over SSH
2026-08-17Ready when you are.
Try ServerEngine free for 7 days.