Windows Updates


I’m pretty much a beginner when it comes to Powershell and just recently, I was tasked with writing a script that enables the computer to download and install updates automatically.

This script is then supposed to be deposited within the Taskplaner.

And I could use some help with structuring and writing this script. :slight_smile:

Kinda regards.


Welcome to the forum. :wave:t4:

Did you try to search for a script first before you came here? Questions like this have been asked a lot of times before and have been answered a lot of time before.

Regardless of that - instead of a potentially quirky and error prone beginner script you should urgnetly consider using WSUS. It is free of charge and it is made for managing updates for Windows clients and server.

I did already search for a potential script but couldn’t really find anything useful.

Most of the results were based on WSUS indeed.

However, I didn’t want to simply copy a script because otherwise, my colleagues would probably notice this because it would be too advanced for a known beginner like me, hence why I hestiated to do this.

Whenever I tried to install WSUS for Powershell, I’d receive an error saying that it wasn’t recognized as a proper cmd.

If this is a homework assignment or something like this you should discuss the task with your tutor/mentor/teacher. To replace a sophisticated, robust and industry wide common solution with a beginner script is actually a bad idea.

If you have code giving you errors you should post this code here along with the error messages and we can try to help you.

Please always format code, error messages, cosnole output or sample data as code using the preformatted text button ( </> ).

Thanks in advance.

It’s no homework, it’s for the improvement of the company I work for. The thing is that the occuring error message is in german, hence why I didn’t post it here in the first place.

Please don’t get me wrong … do you really think you could make it any better than Microsoft can with WSUS? :wink:

First of all - you could have translated it. :wink: And second - there are some Germans around here. Das weiß ich aus sicherer Quelle. :stuck_out_tongue:

Ich habe nie behauptet, dass das Skript WSUS ersetzen soll, selbst beim Installieren davon taucht dieser Fehler auf. :wink: Vor allem geht es darum, dass man einen Lerneffekt mit drin hat. Soweit ich das verstehe, muss man bei WSUS gar nicht viel selbst machen. ^^

Es sollen lediglich Updates automatisiert laufen, was wiederum zur Verbesserung führt → Verbesserung des Unternehmens.

Es zu übersetzen wäre langwierig gewesen und konnte ja nicht wissen, dass hier auch deutschsprachige Personen sind, wenn alles in Englisch verfasst ist. ^^

Es bleibt aber trotzdem immernoch ein englisches Forum und deswegen machen wir auch bitte in Englisch weiter.

I’m not experienced with WSUS - we use SCCM to deploy updates - but I think you have a misconception about the WSUS PowerShell module. As far as I understood comes the module together with the installation of the WSUS server. The cmdlets are not meant to be used on clients. They are designed to manage the server.

You may find other modules in the PowerShellGallery they do what you want. But I’d recommend to use the built in mechanisms to deploy and install updates on clients. I’d expect these to be more robust and reliable than a script.


It looks like we are talking past each other or I’m simply bad at expressing myself.

I can see why you think that WSUS is the solution, however, keep in mind that the script I would write will be checked thoroughly before going into action. Like I said: the task is to write a script and learn powershell and not use already configured clients / server to do the job for me. :slight_smile:

Maybe a little bit of both. :wink:

OK, but as I already said I think you’re using the wrong tool. The cmdlets you try to use - according to the error messages you posted - are usually not available on clients. They are meant to be used to manage the WSUS server.

That’s why I recommended to search the PowerShellGallery for a module offering the functionality you need.

But maybe I’m wrong. You should post the command you used to install the WSUS module and the error messages you get.

I’m not quite sure but I think it was this one.

Install-WindowsFeature UpdateServices

I have also been given a powershell book, thus learning it step by step, I’m currently trying to create my very own user, but also have a few issues here and there.

??? Really?

WSUS is a feature and with this command you would install it ON A SERVER!

I don’t know what to answer you: This has nothing to do with your initial question.

If you want to get help you should ask a specific question about a particular piece of code you wrote and you have issues with. In this case you should post this piece of code here (fomratted as code) along with the error messages you might get (formatted as code) and/or a description what is or how is it not working as expected.

Okay, will do so, just wait a bit.

So, in order for us to get back to the windows updates.

Since the codes I’m working with have absolutely nothing to do with my initial question, I’d like to refrain from them completely.

Do you have an example for a script that could initiate the windows updates? Like I said, I’m supposed to write the code myself and am still learning.

1 Like

Thank you, but I’d still have to do that manually.

The script needs to work under the task planer and thus automatically and at a certain time / date. :slight_smile:

What exactly? You have to share what you’re refering to.

If you found something fitting for you you have to set up your task planer to run it automatically.

I was refering to your solution, it’s still something I’d have to do manually.

No, I simply explained what I’m asking for and what the end result is supposed to be. :slight_smile:

A different question regarding PowerShell: Just recently, I started to receive this error message when trying to run a script.

Missing type name after ‘[’.
+ CategoryInfo : ParserError: ( ) , ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingTypename
What does it mean exactly?

I did not post a solution. The link I shared was a Google search. This Google search brought up 3 or 4 promissing links to solutions regarding your task - at least it did when I searched for it.

Again: You should post the code you used when the error occured (formatted as code please) along with the complete error message (formatted as code please).

Regardless of that - it is recommended to open a new thread if you have a new question unrelated to the initial one.