command line / batch file install updates and restart or shutdown

I'm looking to run a batch file in my organization

 Shutdown /s /f /m \\Computer1
 Shutdown /s /f /m \\Computer2
 Shutdown /s /f /m \\Computer3
 Shutdown /s /f /m \\Computer4

but I want to install any pending updates first.
Is there a way through a script / batch file , powershell that this can be done that I can run as a scheduled task from a remote computer.

From a windows 7 computer ( my computer ) I want to have a scheduled task that  runs ever day at 4:30 AM which will install any pending updates on a computer in my organization and then shutdown the computer or restart the computer.
Any thoughts and answers are appreciated
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Toni UranjekConsultant/TrainerCommented:
Updates are installed with this command: wuauclt.exe /detectnow /updatenow

You would have to use PowerShell remoting Invoke-command cmdlet, or psexec or winrs to run this command remotely.
EkuskowskiAuthor Commented:
My goal:
If a computer(windows 7 Pro ) has updates that have been downloaded but not installed. I want to send a command that will install the updates and then restart the computer.
Would  "wuauclt.exe /detectnow /updatenow" accomplish this ?
Toni UranjekConsultant/TrainerCommented:
/detectnow checks for latest updates.
/updatenow installs them.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

EkuskowskiAuthor Commented:
OK , I am going to use PsExec to remotely run /update
Then later in the night I am going to run shutdown /r /s \m \\computer1 to restart each of the computers
Toni UranjekConsultant/TrainerCommented:
How will you know, when updates are actually installed? ;)
wuauclt returns prompt immediately with no messages.
EkuskowskiAuthor Commented:
I'm going to run wuauclt at 1:00 AM everyday through a scheduled task and then reboot at 4:30 AM, I will not know if the updates completed but since all my computers are basically updated, I think 3 hours to install will be enough time.
Toni UranjekConsultant/TrainerCommented:
OK, you do not have to run wuauclt from cmd to achive that.
Default setting is:

Client setting
EkuskowskiAuthor Commented:
Yes, but some of our computers are set to download only. We are actually going to implement System Center to start managing the clients
Toni UranjekConsultant/TrainerCommented:
OK, good luck.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.