Shutting down or restarting the server
I just couldn't resist starting with this one. Yes, this seems trivial. Silly even. However, the number of times that I have watched a simple server restart consume more mouse clicks than creating a domain controller has convinced me that this needed to be in the book. Perhaps the shutdown and restart options were hidden away purposefully, because once your system is up and running, there is not often a need to accomplish either of these tasks. When first configuring the box, though, it is very common to have to reboot a couple of time or to shut down a machine to move it to another location. Let's face it, it doesn't seem to matter how many years computers have been around, many times the magical reboot is still the fix—all answer to most problems, even if we have no idea why.
Getting ready
To go through this recipe, you will need a Windows Server 2016 system online. There are no other prerequisites.
How to do it…
Let's take a look at three different ways to shut down or restart your system. The first is going to be the most commonly employed. The second is still being used by quite a few folks who had to work hard at getting this strange location in their heads during the Windows 8 rollout, and they have continued to use it from that point forward. The third is less commonly known but is by far my favorite when tasked with restarting a remote server.
The first option, thankfully, is in a location that actually makes sense. I say thankfully because when Server 2012 was released, this option didn't exist, and finding the restart function was much more difficult. Just like we had always been able to do prior to the Windows 8 rollout, we can simply click on the Start button, and see right there near the bottom that we have Power control options available to us.
Now, when you click on Shut down or Restart, you are asked to supply a reason why you are restarting. Common sense tells us that if you are manually clicking on the Restart button, there is a pretty good chance you are actually intending to restart the server, right? A planned occurrence? But what is the default option that presents itself? Other (Unplanned). Alas, this silly default option is certainly going to cause us log files full of unplanned restarts, even though all of those restarts were actually planned. Because let's be real—nobody takes the time to change that dropdown menu before they click Continue.
The second method to accomplish shutting down or restarting is by right-clicking on the Start button. We will discuss this little menu that is presented when right-clicking on Start in our next recipe, but for the sake of a quick shut down or restart, you can simply right-click on the Start button, and then choose Shut down or Sign out.
Each of the previous two examples runs the risk of rebooting the wrong system. Depending on how many layers of remote connections, such as RDP, you are using, it is fairly easy to reboot your own computer or the wrong server instead of the server you intended to reboot, because it is fairly easy to click on the Start button of a different system than the one you intended in the first place. The most definitive, and dare I say the most fun way of restarting your server is to utilize a Command Prompt. Doing this gives you the opportunity to double check that you are manipulating the correct machine. Open up a Command Prompt and run a quick hostname check to make sure you are restarting the one you really intend to. Then utilize the shutdown
command to take care of the rest. This process can be especially helpful when logged into remote servers using RDP. Use the following commands to perform the explained operations:
hostname
shutdown /r /t 0
If you were to simply type shutdown
, the server would shut itself down in 60 seconds. Using /r
indicates a restart rather than a shutdown, and /t 0
is a timing flag that indicates the number of seconds the server should wait before restarting. Specifying slash zero here tells it to wait for zero seconds before initiating the restart.
How it works…
Shutting down or restarting a server doesn't require a lot of explanation, but I hope that this small recipe gets some thought going about creative ways to do regular tasks. As you will see throughout this book, you can accomplish anything in Windows Server 2016 through the use of commands or scripts. You could easily turn the shutdown
command, the last example that we tested in this recipe, into a batch file, and place it on the Desktop of each of your servers as a quick double-click option for accomplishing this task.
However, I work with RDP windows inside RDP windows very often. When you're bouncing around between a dozen servers that all have the same background image, I have decided that the only sure-fire way to make sure you are restarting the correct device is to do a quick hostname
check before you initiate the restart. If you are interested in discovering all of the available flags that are available to use with the shutdown
command, make sure to type in shutdown /?
sometime to take a look at all of the available options.
Tip
Using the Command Prompt is also an easy way to log off a server. Let's say you are layers-deep in RDP and want to log off from a single server (not all of them). Are you sure you clicked on the Start button of the right server? Instead, open up a prompt and simply type Logoff
.