Ever wonder how you can reboot a server,
whether it’s your own server or somebody else’s?
Well, you could do both.
I’m going to show you how to do that in three different ways.
All that and more, coming up now.
Hello, everybody. My name is Adam Gordon,
an edutainer here at ITProTV,
back with another fun and exciting episode
about how do I do all that crazy stuff you want do in server,
but were afraid to ask.
Well, guess what?
We’re going to ask those questions for you
and we’re going to answer them in this ongoing conversation
we have with you on our YouTube channel.
And by the way, speaking of YouTube,
if you want to check this episode out and all the others,
why don’t you go on over there and subscribed.
You can check us out on an ongoing basis,
we’re always putting new content out
and always keeping it fresh and real, as they say,
to keep you educated, keep you on the cutting edge
of how you can optimize your server experience.
If you need more deeper technical conversations
about managing infrastructure,
whether it’s Microsoft or any other technologies,
well, check us out right over at ITProTV
where myself and all the other edutainers
are waiting to spend time with you,
helping you to figure out those complex problems
and make sure you know exactly what to do,
and how to do it securely.
In this conversation we’re going to be taking a look at
how you can schedule a restart event for your server.
Now, that may sound pretty simple to you,
“Well, Adam, why don’t I just go click on the start menu,
go restart from the GUI
and just physically restart the system
when I’m sitting at it, or maybe remote in
and do it from a remote connection?
”Well, you’re absolutely right, you could do that,
and that is logically how many people tend
to restart their servers.
But, what if you’re not going to want to get up
at 2 in the morning and have to deal with that,
either in person, or remotely,
and you want to set it and forget it, as we often say.
Well, I’m going to show you
how to schedule those events to take place.
We can leverage a couple of different technologies to do that.
We could do it using the Task Scheduler,
we’ll take a look at that often overlooked tool
buried inside Microsoft Windows,
it’s been there going all the way back to Windows 9X,
it’s been there forever.
Well, we’re going to take advantage of it
to create a task and show you
how you could set that task up
to restart the system exactly when you want it,
under the right conditions.
I’m also going to show you
how to do that from the Command line,
you can use that same program
that we’re going to call in the task,
shutdown.exe is the name of the program, but be careful,
you don’t want to use this without paying attention
to what your targeting it at,
or you’re going to restart your system when you don’t mean to.
We’re going to take a look
at how we can call that from a command line,
executing that in a script
and/or how we can actually use the graphical interface,
the GUI associated with the program shutdown.exe,
to target remote systems if necessary,
and all us to specify how we want them to be shut down,
as well, as long as we have permission to do so.
Join me here, let’s take a look
at all this fun, exciting, and cool stuff we can do to really,
well, get in there and restart that system if we need to.
Alright, I’m not going to bother
to show you where we go to the Start menu
to be able to access those restart options.
We talked about those are in the GUI menu
and I’m pretty confident you’re going to be familiar with
how to find them.
But, we are going to go the Start menu
to find the Task Scheduler.
This is often a tool that, as I suggested,
people not only overlook, but actually don’t even know is there,
and certainly don’t know where to find,
so it’s worth a moment of our time.
We’re going to go to the Start menu
and we’re going to go over here
and I’m just going to zoom in, in just a second,
so you can see this.
I just want to show you
where we’re going to go before we do that.
Windows Administrative Tools is where we’re going to go
and we’re going to pull that down,
I’m going to scroll down
so we could see that long list of tools there,
and almost at the very bottom, right there,
is the Task Scheduler, between System Information
and The Windows Defender Firewall with Advanced Security.
So, we’re going to click Task Scheduler,
that’s going to open up just like that.
Now, I’ve already got it open,
so we’re just going to go ahead, minimize that,
and bring up the one that I’ve already set up.
The Task Scheduler is going to be a Graphical User Interface,
GUI for the AT,
the AT Command Line Scheduler which can be accessed
from the Command line to do the same thing we’re about to do.
Again, these technologies have been in Windows
since the earliest, earliest, earliest days,
all the way back to Windows 9X in one form or another.
We’re current on Server 2022,
you can go back and look at any version of Windows,
you’ll find a Task Scheduler, you’ll find the support
for the AT Command Scheduler in the Command line,
and you’ll find the ability
to work with shutdown.exe is there consistently.
So, nothing new, just really putting a new spin
on how to package those skills
and put them together for you
with regards to our conversation.
Now, the Task Scheduler has been updated
and changed over the years, it looks a little bit different
than it might in earlier versions of Windows.
So, the specifics of the interface
are worth just a moment of our time.
As we open the Task Scheduler,
we’ll see right above where I’m highlighting,
which is Task Scheduler Library,
we have the Task Scheduler (Local),
and that is the Task Scheduler for this machine.
What that does is really just show us an all-up view,
in this case right now I have 67 total tasks scheduled
and running at some point throughout a normal 24-hour,
perhaps 6 or 7-day, of 1-month view of the system.
These are scheduled tasks that Microsoft has set up
and has put into the operating system
often behind our backs, so to speak,
meaning, without our knowledge,
not in a negative or bad way,
but simply to maintain the integrity
and the operational capacities of the operating system
and optimize them.
Occasionally they will add new programs in,
they may schedule their own tasks
to drive some sort of automatic cycle
or a variety of things to beacon and call home,
or whatever the case may be.
We can see a list of all of them right down here,
and we can interact with one or more of them,
highlighting it, and we can double click
and be taken exactly to where that exists,
see the category it’s in, see the properties,
and manage it, and do all sorts of stuff with it.
We’re not going to spend on how to do that now,
but I’m looking at the Windows Reporting area
for the Queue Reporter
which tells Microsoft when there’s an error,
and then uploads that information
if we opt in and allow that to happen,
there’s a task that’s scheduled to do that automatically.
But, what we’re interested in is the ability
to be able to go one level down
from the Task Scheduler (Local) view,
we’re interested in going to the Task Scheduler Library,
where I was as we came in here,
you can see it highlighted right there,
and below that is, as you saw, a series of folders,
getting more granular as we go,
giving us access to all elements of any and all programs
and areas within the system
that allow us to schedule,
and indeed, execute and run one or more tasks.
So, we see all that there, and any tasks that we have
current scheduled or set up our own,
that we’ve created separate from the automated ones
that Microsoft sets up and maintains for us,
that we just looked at, will be found here.
We can certainly see a list of them right here.
We’ll see the Restart Server tasks,
the two of them I have are the ones I’ve created.
Now, I can do this in a variety of ways.
I can right click right here, and I have some options.
I can Create Basic Task,
it’s really just a very slimmed down optimized version
of the Task Wizard,
doesn’t ask me a lot of advanced complicated questions
that I have to answer to Create a normal or full Task,
that’s the second option down, as you can see right there,
or I can Import an existing Task
that somebody else has created and that I want to use.
And I can export them from another machine,
and import them here.
And I have some other options about
looking at running tasks and things like that.
Now, if you want to create just a basic task,
it’s very straightforward.
You give the task a name, I’ll call this Adam Task 1,
and I’m just going to go ahead, highlight that
just you can see the name right there,
and then we’ll click Next.
I have to specify when I want that task to start,
what will be what we call the Trigger, daily,
weekly, monthly, is it a single one time event,
when the computer starts,
when I log on, when a specific event is logged,
and I have to specific what that is.
So, I’ll just go ahead
and say I want this to be a One Time event,
notice it changes,
if I say I want when a specific event is logged,
notice I have to choose when the event is logged,
when I log on, when the computer starts,
does not require any choices.
So, I’ll do One Time and I have to specify the day
and time that I want that to occur.
We’ll go ahead and specify that that will happen at 10pm.
Alright, next, and then what do I want to do?
Well, in our case, we want to use shutdown.exe,
so we’re going to start a program,
but notice, I can send an email
and/or display a message,
but notice in parentheses it says (deprecated).
What that means,
Microsoft is indicating that in a future release of this tool,
those options are very likely to disappear;
for now, they’re here,
but we’re probably not going to have access to them forever.
But, running a program, we certainly will.
So, we’re going to choose Start a program.
We have to know where that program lives,
so we have to have the path to that program,
the path to shut down the system using shutdown.exe
is the C:\WINDOWS\System32 directory string,
so we put that in, name the program,
and that’s fine, that is there,
and all I have to do is simply type that in,
paste it as I did,
or browse if I don’t know where to go, but I can find out.
I could also add arguments if a want to,
maybe adding in one or more of the switches,
-i to bring up the graphical interface,
-a, f, s, et cetera, whatever they are.
If you’re not familiar with those switches,
I’ll show you how to find them in a moment,
and I can put them in here
and I can specify how I want that system
to actually set up run the task
with the additional arguments, if necessary.
All that can be done.
Click Next.
I go to Summary on my task.
I can go ahead
and open the properties of the dialogue for the task
if I choose to, or just click Finish,
that will pop in here almost immediately.
If for any reason it does not, just come over here,
I see on occasion it doesn’t pop in right away, hit Refresh,
you can see it right over here off to the right,
and when you refresh, that should pop in
and we should see it, and sure enough, we see it there.
I can see the properties,
I can see it’s got a tabbed interface
with the General, Trigger,
Action, Condition, Settings, et cetera.
Now, if I create, not a Basic Task, but simply a Task,
I’m asked all these additional questions
and I can go in and I can look at all of these,
not just the things that we answered,
but additional things that I might want to specify.
It’s a little bit more granular in its capabilities
and we can make those choices if we choose to.
So, this is the first way we can set up
and schedule a restart event.
We can create a Schedule Task
using the Task Scheduler from the GUI interface,
calling the shutdown.exe program.
So, check off, number one is good.
Let’s minimize this.
Let’s take a look at our second way that we can do this.
I specified and told you that we could do this
by running the shutdown.exe program.
We could do that from the Command line, I suggest,
and we could set this up
as some sort of scheduled option inside of a script.
Well, we could do that from PowerShell
is usually a good way to do that.
So, I just went into PowerShell,
opened it up as an administrator
and you can see I’m running PowerShell
with admin privileges right at the upper left hand corner.
And what I did is simply pasted in the same path statement,
C:\WINDOWS\System32\shutdown.exe.
But, instead of running it and setting up a script,
I put the /? at the end, because I said,
hey, I’m going to show you
where you can find all those switches
if you’re not familiar with what they are.
And sure enough, if you read the help file,
which is what we’re seeing here,
you can find all the arguments or switches,
as Microsoft refers to them,
and you can see a complete list of them here,
there are several of them, as you can see,
and they give you the details of all of the values
that can be specified that might be used.
And so the one that is of interest to us,
we’re not going to write a script to do this,
you could simply set this up in PowerShell,
calling shutdown.exe directly,
and use one or more of the arguments,
that would be one way.
We could load this half statement into a small script file
and then schedule that script to run from
within the Task Scheduler, that would be another way.
I could simply have that script available
and invoke it on demand, that would be yet another way.
So there’s multiple ways to use the Command line
to be able to engage this restart activity,
it’s really up to us to decide.
But, having said that,
I want to focus right here on the /iswitch displays
the graphical user interface, the GUI.
I promised you at least three ways to do this,
and I said one of those ways would involve using the GUI,
the graphical user interface for shutdown.exe
to let us target remote machines.
Well, most people don’t realize if we run shutdown.exe
with the /i switch, we get that GUI.
And so if we do that,
I’ve opened up a separate version of PowerShell
where I can do just that, and you’ll see
I’ve already got the command typed in there,
it can be /i or -i, it works either way,
and when I do that,
what happens is I don’t restart the machine,
but rather I get a GUI interface
that allows me to program in
how I want the restart to happen, similar to what I did
with the Task option in the Task Scheduler.
But, I get the remote shutdown dialogue,
I can add computers to this list to target them,
either a local machine or a remote, click Add,
and type in the name, and I keep adding names as I go.
I can then specify what I want these computers to be doing.
Do I want them to Restart, do I want them to Shutdown,
or do I want an Annotated Unexpected Shutdown,
where I want to write something down,
make note of it, whatever.
So, I have different options here,
meaning if there was some sort of event
that shut down the system,
I want to make a note about that,
maybe it was a power outage, or something, right?
So, I could specify a restart, for instance I can click Add,
and notice I can add computers in
by specifying their name and/or notice I can browse
and when I browse, notice,
I have to have Active Directory Domain Services
to be able to browse for machines in the directly,
pull them in, and target them.
Remember, I said I need rights to the machine.
Well, as a domain admin in the Active Directly,
I would have rights to all those machines.
As a local administrator on a standalone machine,
I only have rights to my own machine,
I don’t have rights to anybody else’s.
So, we’d have to obviously be running in a domain
where the active directly is enabled.
We’re not setting that up for this demonstration,
but just want to show you that capability and show you
and give you an option to think ahead about that.
We then would go ahead, we could display a warning
for a certain period of time if we choose to,
warning the remote users before we do this.
We could specify the option
that describes this shutdown event in the tracker,
and specify that for essentially recordkeeping purposes,
and I can make a comment here if I choose to,
like, Adam is restarting to align with our SLA window,
or something like that.
And so if I typed in the name of a machine,
we’ll call this the Melissa 1 machine,
and I click okay, I’ve got the name there,
assuming that machine really exists and we can target it,
we will be able to reach out and swat that machine.
And if I go ahead and I do Shutdown instead of Restart,
I’ll be able to display that warning, and I can specify that.
And then, once I am done,
I’ve done all this and I put that in,
notice I need to acquire all that, if I click OK,
the system will go out
and try to find the Melissa1 machine,
it doesn’t exist, I just made it up,
so we’re not going to do that,
but if there was one, I would target it,
assuming I had rights,
I’d be able to execute the shutdown sequence
or the restart sequence,
depending on what I’m doing,
and I’d be able to reach out
and restart or shut down that machine.
So, a minimum of three ways to use shutdown.exe
both with the Task Scheduler from the Command line directly,
and bring up the GUI, target remote machines
with Directory Services supporting us
to be able to enable the permissions necessary to do so.
So, keep that in mind.
But I have options, and options are good,
and you do, as well,
because you’ve seen the multiple ways
that we can use shutdown.exe to target
and ultimately set up a restart event if we choose to.
I’ll be back with more exciting continuing conversations
about how you can optimize your Windows server experience.
I’m going to go get ready for those,
but until I see you again,
I’m going to wish you happy servering,
and I’ll see you soon.