Hello, my name is Curt. I'm a Senior Principal Engineer working with the GSE Team. This video
is dedicated to demonstrating how to use Windows PowerShell to install and uninstall a Windows
Update Package. We'll look at the requirements for preparing PowerShell to manage and install Windows
Updates and we're going to focus on the specific cmdlet we're going to use, and the direct commands
involved. So we have a list of seven commands here, and the one at the top actually installs
the module that we're going to be using in this demo, and it's a program called PSWindowsUpdate,
and once we install that it gives us an option to run the commands. Following that we're going to
look, go through a list of commands to discover the history of the updates that have gone on,
we're going to look at the updates that have been found that need to be put on, and we're actually
going to be able to check the status of Windows Installer as well on the system using PowerShell,
and we're actually going to do some installs with PSWindowsUpdate.
So let's go ahead and get into the demo itself of what we're trying to do here. So this
is the installation command to put in the module for PSWindowsUpdate.
I'm going to go ahead and run that. There we go.
And this can take a little bit of time to include, to put in, uh so the installation just completed.
Now I had previously installed this module and actually uninstalled it, so the program bits for
it were already on the system. You will normally see when you do the install, it will ask you if
you want to update your NuGet provider, also it may be asking you to approve the install.
So we're going to go ahead and run the next command it's ‘Get-WUHistory’.
This is specifically designed to find out what has been installed, and here's
a list of commands. This is a new system I just recently set up so this is a pretty short history.
This is a command I really like sometimes when troubleshooting because if we're trying
to discover failures and trying to troubleshoot why given updates aren't working this is a great
command that you can pipe to a notepad file and just peruse and find out the overall failure
history of the system. So that's one thing to keep in mind for that particular command.
So the command that we can run to find out what updates are eligible for the system
is ‘Get-WindowsUpdate’ so let's go ahead and plug that in, so try to copy that this time,
there we go. And once again this is going to tell us what
we should be installing on the system to get it up to date,
and this command can take a little bit of time because once again
it's doing a check with the Windows Update Servers back at Microsoft. Okay,
so we have three listed updates that we are eligible to put on.
Now there's another command that's a bit interesting to run,
and it involves just finding out the status of Windows Update Installer.
It's a pretty simple command, and it gives a simple response. If Windows Update is
not in the process of doing an update, we'll come back with a ‘false’ response.
All right so we're going to actually do an install at this point
and I’m going to pick out one of the updates that's not all that large.
Now this is, this is syntax for this ‘Get-WindowsUpdate -Install
-KBArticleID’. So we have a list of updates we can put on here just for demo purposes. Once
again I’m going to be picking one that's going to run quickly, or relatively quick I should say.
Okay, let's try this again,
and we're going to select the malicious update one, there we go.
And this is a little bit of what it looks like. It's going to ask you if you want to approve that
update, go ahead and select all, and it's going to go ahead and perform the update.
So I went ahead and
did a pause on my video, and that update actually did install. So it went through the process,
it actually took a while, it took much longer than I expected but it did complete. So there is
a removal command. I will let you know that in trying to work with this command I’ve had some
unexpected results that didn't really, didn't actually remove the command. I got different
messages as to why it didn't want to remove it, so this, the removal command itself you can use
at your own risk I guess, but there are other methods to remove updates outside of PowerShell.
For right now I ran into several different issues trying to use the remove, but it is available,
and you can attempt to use it if you want to try to use PowerShell to remove updates,
so it does exist. So, the last command that
we will run is a command that will find all the available updates that should be applied,
and this specifies that we're going to accept all those updates so that we don't have to respond to
each one of the individual updates that are being put on. It's going to go ahead and do the install
and this particular parameter, ‘-AutoReboot’ is going to reboot the system if the update demands
that. Now there are parameters to prevent the auto reboot, so ‘-IgnoreReboot’ is one of those
parameters, so that exists as well if we can't reboot the server. But we're going to go ahead and
go ahead and put this command in. We're going to attempt to anyway.
Okay, there we go. This is real similar to our last update,
it's going to kick off and it's going to run. I’ve already done a test for this particular install,
it takes about 40 minutes to install so we're not going to hang around for that,
but that gives you an example of what you can do with PowerShell when it comes to
installing Windows Updates. So that concludes our demo on
using Windows PowerShell to install and uninstall Windows Update Packages. Thank you for watching.