Cmdlet for Detect and install update + reboot

Can
Can used Ask the Experts™
on
Hi Guys,

I have around 100 servers in a test environment which i need to update on specific days. An GPO is not an option. Is there any script which i can use? What i would like to have are the following:

1. Search for windows updates on WSUS
2. Install all available updates
3. Restart
4. Detect again

Something like "wuauclt /detectnow /reportnow" with an restart option would be perfect -shutdown /r does not work.

It would be even better if i can enter computernames.

Thanks in adcance.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
DevAdminSystem Engineer | .NET Developer | Microsoft MVP | Technical Speaker

Commented:
try read my post
https://www.devadmin.it/2018/11/20/forzare-lesecuzione-degli-aggiornamenti-in-windows-10-e-windows-server-2016-2019/

REM WaitTime 30 minute (1800 sec)
SET WaitTime=1800

REM Scan Updates
%systemroot%\system32\UsoClient.exe StartScan
 
REM Wait scan to complete
timeout /t %WaitTime%

REM Download updates
%systemroot%\system32\UsoClient.exe StartDownload

REM Wait Download to complete
timeout /t %WaitTime%

REM Install updates
%systemroot%\system32\UsoClient.exe StartInstall

REM Wait Install to complete
timeout /t %WaitTime%

REM Restart Computer
shutdown /r /t 0 /c “Restart after force install updates by script”
CanSystem Administrator

Author

Commented:
Hi,

Unfortunately i dont understand italian. The command i need, needs to do the following :

Check update>Install>Restart if needed>Check update.

Thanks.
DevAdminSystem Engineer | .NET Developer | Microsoft MVP | Technical Speaker

Commented:
You can do with UsoClient do you try the script that I write in my previous answer?
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

CanSystem Administrator

Author

Commented:
Hi Ermanno,

I have tested it. I get a few errors. Please check the attachment.

Thanks.
2019-01-19-13_19_36-Windows-PowerShe.png
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
Ermanno provided a CMD batch, not a PowerShell script.
CanSystem Administrator

Author

Commented:
Hi Qlemo,

Thank you for the info. The bat file works. Yet i have a question about the 1800 seconds. is there any option to continue when the task is done instead of waiting 1800 seconds after every task?
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
The issue with the UsoClient is that it is asynchronous, and returns immediately - you don't get any info back when the job is done.
That is also the reason why the script does not have a way to tell  whether there have been updates.

By parsing the update logfille it might be possible to get some state info, but that requires significant effort.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial