Link to home
Start Free TrialLog in
Avatar of Can
Can

asked on

Cmdlet for Detect and install update + reboot

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.
Avatar of DevAdmin
DevAdmin
Flag of Italy image

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”
Avatar of Can
Can

ASKER

Hi,

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

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

Thanks.
You can do with UsoClient do you try the script that I write in my previous answer?
Avatar of Can

ASKER

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
Ermanno provided a CMD batch, not a PowerShell script.
Avatar of Can

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial