As a system administrator, one of the essential skills you need to master is the ability to efficiently manage and troubleshoot servers. This includes knowing how to restart a Windows Server using command-line tools. This article delves into various methods and tricks to restart Windows Server using the command line, a crucial technique for quick and effective server management.
To reboot a Windows server using the command line, you can employ the /r
switch with the shutdown
command. This article provides various examples of how to use command line instructions to restart Windows systems.
- Restart Computer: For restarting a local Windows system, use the following command:
shutdown /r
- Restart Forecefully: To restart the local system and force all running applications to close, include the
/f
switch:shutdown /r /f
- Adding a Timer: Optionally, you can add a delay to the restart process. For instance, below command will restart the server after 60 seconds.
shutdown /r /t 60
- Restart Remote Computer: If you need to restart a remote system, include the system’s hostname with the
/m
switch:shutdown /r /f /m \\REMOTE-PC
- Adding Comments: Additionally, you can add a comment to document the reason for the reboot using the
/c
switch. For instance, if you are restarting the system after installing software, the command would be:shutdown /r /f /m \\REMOTE-PC /c "Post Installing Software"
These commands offer a streamlined and efficient way to manage system restarts directly from the command line.
Using PowerShell
For those who prefer PowerShell, the process is similar but uses different commands:
- Open PowerShell: Search for it in the start menu or type powershell in the Run dialog.
- Restart-Computer Command: Use the command
Restart-Computer
. This straightforward command initiates an immediate restart of the server.Restart-Computer
- Adding Parameters: Similar to Command Prompt, you can add parameters like
-Delay
to set a timer for the restart.Restart-Computer -Delay 60
- Restart Remote Server: If you need to restart a server remotely, you can use the following command in PowerShell:
Restart-Computer -ComputerName [ServerName] -Force
Replace
[ServerName]
with the actual name of the server. The-Force
parameter ensures that all running applications are closed immediately.
Conclusion
Mastering the command line for restarting Windows Server is a vital skill for any system administrator. It provides a quick, reliable, and scriptable method to manage servers, especially in complex or remote environments. By incorporating these tips and tricks into your routine, you can significantly streamline your server management tasks.
Remember, while the command line is a powerful tool, always proceed with caution and ensure you have backups and a recovery plan in place for unforeseen circumstances.
Простым решением является перезагрузка. В этом руководстве вы узнаете, как перезапустить Windows Server 2016 с несколькими параметрами команды.
Перезагрузить Windows Server через графический интерфейс
Интерфейс Windows Server 2016 представляет собой графический интерфейс, который упрощает многие задачи.
Нажмите: меню Пуск -> Кнопка питания -> Перезагрузить.
Как перезагрузить Windows Server с помощью командной строки
В некоторых случаях у вас может не быть установлен компонент GUI. Или ваша операционная система столкнулась с проблемой, и все, что вы можете получить доступ, это командная строка.
Шаг 1: Откройте командную строку
- Нажмите Ctrl + Alt + Del.
- Система должна показать меню — щелкните Task Manager (Диспетчер задач).
- В окне Task Manager (Диспетчер задач) нажмите More Details (Подробнее).
- Откройте меню File (Файл) и выберите Run new task (Запустить новое задание).
- В поле введите
cmd.exe–
, затем установите флажок, чтобы создать задачу с правами администратора. Нажмите ОК. - Должно появиться черное окно с белым текстом.
Шаг 2. Перезагрузите операционную систему Windows Server.
В окне командной строки введите команду перезагрузки Windows Server и нажмите клавишу Enter:
shutdown –r
Параметр –r
заставляет Windows перезагружаться, а не просто выключаться.
Перезапуск из PowerShell
Windows PowerShell напоминает расширенную версию командной строки. Он основан на .NET Framework и включает язык сценариев. PowerShell полезен для работы под операционной системой Windows.
Шаг 1. Запустите PowerShell
- Нажмите Ctrl + Alt + Del и выберите Task Manager (Диспетчер задач).
- Откройте меню File (Файл) и выберите Run new task (Запустить новое задание).
- В командной строке введите
powershell.exe
и установите флажок, чтобы начать с правами администратора. Нажмите ОК. - Должно открыться новое окно с темно-синим фоном. Вы можете понять, что находитесь в окне PowerShell, если подсказка начинается с
PS
.
Шаг 2: перезагрузите систему
В окне PowerShell введите следующую команду и нажмите Enter:
Restart-Computer
По умолчанию вы получите 5-секундный обратный отсчет, затем система перезагрузится. Вы можете добавить опцию, чтобы отложить перезапуск на более чем 5 секунд по умолчанию:
Restart-Computer –delay 15
Перезагрузка удаленного сервера Windows с помощью PowerShell
Шаг 1. Запустите PowerShell
Если вы находитесь в командной строке, введите команду:
PowerShell
Подсказка добавит PS
в начале, и ваши набранные команды должны появиться в желтом цвете.
Шаг 2. Перезагрузитесь удаленно
В окне PowerShell введите следующее:
Restart-Computer –ComputerName “NAME_OF_SYSTEM”
Замените NAME_OF_SYSTEM
на имя компьютера, который вы хотите перезагрузить. Не забудьте поставить кавычки.
Примечание. Предполагается, что ваши текущие учетные данные те же, что и для удаленной системы. Обычно это может выглядеть как имя пользователя администратора, и один и тот же пароль для обеих систем. Это также может работать, если обе системы находятся в одном домене, а ваша учетная запись пользователя имеет соответствующие разрешения.
Restarting a Windows Server is crucial for applying updates, troubleshooting issues, and maintaining system performance. Regular restarts help ensure a server runs the latest software, resolves conflicts, and clears temporary files.
This tutorial explains how to restart a Windows server using different methods.
Prerequisites
- A system running Windows Server.
- Access to the Command Prompt.
- Access to PowerShell.
Why Restart a Windows Server?
Restarting a Windows server is essential for applying critical updates and patches that enhance security and performance. It helps resolve software conflicts and clears out temporary files, which improves system stability and speed. It also closes running processes that slow the system down and starts them up again. Restarting is also helpful in troubleshooting network connectivity issues and application errors.
Note: A full Windows server restart clears all processes, ensuring a fresh start. However, using Fast Boot reduces downtime by speeding up the startup process. Still, Fast Boot only applies after a complete shutdown, never when restarting the system. Fast Boot is also more relevant to client versions of Windows, while server environments often prioritize full resets for stability and performance. So, use Fast Boot for personal computers or lightweight server tasks and avoid it for critical servers, troubleshooting, and security-sensitive environments. To set up Fast Boot, access Power Options in Windows settings.
Shutdown vs. Restart
Restarting a Windows server closes all applications and processes, shuts down the system, and immediately powers it back on, ensuring a complete reset of all system components. However, shutting down powers it off completely.
Use shutdown for regular power-offs, especially when Fast Boot is enabled for faster startups. Use restart when applying updates, troubleshooting, or needing a complete system reset to clear temporary issues.
Soft vs. Hard Restart
A soft restart is the standard method for restarting Windows. It involves using the operating system’s built-in restart command or restarting through the Start menu, which closes all running applications and processes before restarting the system.
On the other hand, a hard restart, also known as a hard reboot or force restart, involves forcibly cutting power to the system by holding down the power button until the system shuts down or disconnecting the power source and then turning it back on again. This method is used when the system becomes unresponsive and cannot be restarted using the usual soft restart method.
How to Restart a Windows Server
There are several ways to restart a Windows server, such as the Command Prompt, PowerShell, or via the GUI. The following text presents a few ways to do that.
Note: Save all work before restarting your server to avoid losing any data or halting the process.
Restart the Windows Server with the GUI
The Windows Graphical User Interface simplifies many tasks, including restarting servers. To restart the Windows server via GUI, take the following steps:
1. Click the Start menu.
2. Select the Power button.
3. Click Restart.
Restart Windows Server via Command Prompt
If the GUI is not installed or working, other options exist for restarting your Windows server. One of them is to use the Windows shutdown
command. The Windows shutdown
command allows you to shut down, restart, log off, or hibernate your computer from the command line. Its syntax is:
shutdown [options]
The shutdown
command has plenty of options, but the one relevant to this tutorial is -r
. The –r
option tells Windows to restart instead of shutting down.
To restart the Windows server, access the Command Prompt and enter:
shutdown –r
The command has no output, but it restarts the server.
Restart Windows Server via Windows Powershell
PowerShell is a robust command-line shell developed by Microsoft. It’s designed for system administration tasks, automation, and managing configurations across Windows-based systems.
The Restart-Computer
cmdlet in PowerShell is used to restart a computer. It provides options to specify the computer name, force the restart, wait for the restart to complete, add a delay before the restart, set a timeout period, and provide credentials if necessary. The command syntax with all available options is:
Restart-Computer [-ComputerName] [-Force] [-Wait] [-For ] [-Delay ] [-Timeout ] [-Credential ] [-Protocol ] [-Confirm] [-WhatIf]
The command consists of:
[-ComputerName]
. Specifies the name of the computer to restart.[-Force]
. Forces the restart without prompting for confirmation.[-Wait]
. Waits for the restart to complete before returning.[-For]
. Specifies how long it takes for the restart to complete (in seconds).[-Delay]
. Specifies a delay before initiating the restart (in seconds).[-Timeout]
. Specifies a timeout period for the restart operation (in seconds).[-Credential]
. Shows a user account with permission to restart the computer.[-Protocol]
. Determines the protocol to use for the restart operation.[-Confirm]
. Prompts for confirmation before executing the restart.[-WhatIf]
. Shows what happens if the restart command runs without actually restarting the computer.
To restart a server, use the command without any options. Access the PowerShell and type the following:
Restart-Computer
You can delay the restart for longer than the default five seconds. For example, delay the restart for 15 seconds with:
Restart-Computer –delay 15
Restart Remote Windows Server
Use PowerShell to restart a remote Windows server. In the PowerShell window, type the following:
Restart-Computer –ComputerName ["NAME_OF_SYSTEM"]
Replace ["NAME_OF_SYSTEM"]
with the name of a server you want to restart. Make sure to include the quotation marks. For example, to restart a remote machine named «Server01», run the following:
Restart-Computer -ComputerName "Server01"
This command initiates a restart of the remote Windows server named «Server01».
Conclusion
Restarting a Windows server is simple, and this article presents several different ways to do it.
Next, learn about the most important Windows cmd commands.
Was this article helpful?
YesNo
Windows · September 28, 2024
Restarting a Windows Server is a common administrative task that can be performed through various methods. Among these, the command line offers a powerful and efficient way to manage server operations. This article will explore the command line method for restarting a Windows Server, detailing the steps involved, the commands used, and some best practices to consider.
Why Use the Command Line?
The command line interface (CLI) provides several advantages over graphical user interfaces (GUIs), especially in server environments:
- Speed: Command line operations can be executed faster than navigating through multiple GUI menus.
- Automation: Scripts can be created to automate repetitive tasks, including server restarts.
- Remote Management: The command line can be accessed remotely, allowing administrators to manage servers without needing physical access.
Prerequisites
Before proceeding with the command line method, ensure that you have:
- Administrative privileges on the Windows Server.
- Access to the command prompt or PowerShell.
Using Command Prompt to Restart Windows Server
The Command Prompt is a built-in Windows tool that allows users to execute commands. To restart a Windows Server using the Command Prompt, follow these steps:
- Open the Command Prompt:
- Press
Windows + R
to open the Run dialog. - Type
cmd
and pressEnter
.
- Press
- Type the following command and press
Enter
:
shutdown /r /t 0
In this command:
/r
indicates that the system should restart./t 0
sets the timer for the restart to zero seconds, meaning it will restart immediately.
Using PowerShell to Restart Windows Server
PowerShell is another powerful tool for managing Windows Servers. To restart a server using PowerShell, follow these steps:
- Open PowerShell:
- Press
Windows + X
and selectWindows PowerShell (Admin)
.
- Press
- Type the following command and press
Enter
:
Restart-Computer -Force
In this command:
-Force
ensures that the restart occurs without prompting for confirmation, which is useful in automated scripts.
Best Practices for Restarting Windows Server
When restarting a Windows Server, consider the following best practices:
- Notify Users: Inform users about the scheduled restart to prevent data loss.
- Check for Updates: Ensure that all updates are installed before restarting to maintain system security and performance.
- Backup Data: Always back up critical data before performing a restart, especially in production environments.
- Monitor Services: After the restart, check that all necessary services are running as expected.
Conclusion
Restarting a Windows Server using the command line is a straightforward process that can enhance efficiency and control for system administrators. By utilizing either the Command Prompt or PowerShell, administrators can quickly execute restarts, automate tasks, and manage servers remotely. For those looking to optimize their server management experience, understanding these command line methods is essential.
For more information on reliable server solutions, consider exploring USA VPS Hosting options that can support your server management needs.
We continue to explore the features of Windows Server 2022. It is well known that this is Microsoft’s next solution for enterprise environments. Well, like its predecessors, this version has variants with and without a graphical environment. In addition, it is well known that a common task is to shut down or restart the server. Therefore, this can be done from the start menu. However, in environments without a graphical plug-in, then we can do it from the command line. Read on to find out How to shutdown and reboot Windows Server 2022 with commands.
How to restart Windows Server 2022
The first thing you have to do is to open a CMD as administrator. Then use the following syntax:
shutdown /r /t time
Please replace Time with the time you want to wait for the server to restart.
This means that after 200 seconds, the server will be restarted. On the other hand, it is possible to add a message at restart time. For this purpose, just add the -c parameter:
shutdown /r /t time -c message
The server will restart after the timeout period has elapsed. On the other hand, sometimes there are open programs that prevent a restart. In such a case it is possible to force a shutdown using the following command:
shutdown /r /f
It is even possible to schedule this task for a remote computer. With this in mind, use the following syntax:
shutdown /r /f /m \\Computer
How to shutdown Windows Server 2022 with commands
The commands for shutting down the server are very similar to that for restarting it. In fact, only the first element changes. So use the following syntax:
shutdown /s /t time
To add a message we use the -c parameter as follows:
shutdown /s /t time -c message
To force applications to close we run:
shutdown /s /f
It is also possible to use it with remote computers:
shutdown /s /f /m \\COMPUTER
Ultimately, we have seen how to shutdown and reboot Windows Server 2022 with commands. Consequently, we have an expeditious way to manage these tasks on the server. Bye!
— Advertisement —
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
«The best Linux newsletter on the web»