Hello, my name is Kurt. I am 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 commandlet 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 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 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. So the installation just completed. Now, I 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 getProvider.
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 is a list of commands. This is a new system that 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". 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. So we have three listed updates that we're eligible to put on.
Now there's another command that is 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, it will 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 up one of the updates that's not all that large. Now, this is the syntax for this "Get-WindowsUpdate-Install-KBArticleID". So we have a list of updates that 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.
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 actually remove the command, I get different messages as to why it didn't want to remove it, so the removal command itself, you can use it at your own risk, I guess. But there are other methods to remove updates outside PowerShell, but 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 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 "AutoReboot", 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 put this command in. I'm going to attempt to, anyway. There we go. And this is really 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.