command line / batch file install updates and restart or shutdown

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

C:
CD\
 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.

So,
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
EkuskowskiAsked:
Who is Participating?
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.
0
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 ?
0
Toni UranjekConsultant/TrainerCommented:
/detectnow checks for latest updates.
/updatenow installs them.
0

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
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

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
0
Toni UranjekConsultant/TrainerCommented:
How will you know, when updates are actually installed? ;)
wuauclt returns prompt immediately with no messages.
0
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.
0
Toni UranjekConsultant/TrainerCommented:
OK, you do not have to run wuauclt from cmd to achive that.
Default setting is:

Client setting
0
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
0
Toni UranjekConsultant/TrainerCommented:
OK, good luck.
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.