Ying Li(MVP) at myITforum.com

PowerShell & System Center

PowerShell Script to Restart multiple Remote Computers

Right before Christmas, PowerShell team released Windows PowerShell V2 Community Technology Preview 3 (CTP3). There is a new cmdlets caught my eye, see below

gc c:\Temp\ServerList.txt |%{Restart-computer –computername $_ –force}

It gets a list of computers and force the immediate restart!

 

It’s very handy and also can be very dangerous, you could potentially reboot every single computer in your company!

Get-QADComuter|%{Restart-Computer –computername $_ –force –throtllelimit 1-}

Comments

jsnover said:

You can also do it this way:

Restart-Computer -Computername (gc c:\temp\serverlist.txt) -ThrottleLimit 16

It will restart them 16 at time.

Jeffrey Snover [MSFT]

Windows Management Partner Architect

Visit the Windows PowerShell Team blog at:    blogs.msdn.com/PowerShell

Visit the Windows PowerShell ScriptCenter at:  www.microsoft.com/.../msh.mspx

# January 6, 2009 11:16 PM

yli628 said:

That's even better!

Thanks Jeffrey.

# January 7, 2009 8:53 AM

apr01 said:

Can you modify this to pull the computer list from a particular OU instead of a txt file?  That would be great. I would like to use this to bulk restart my user pc's, not servers, but want to be able to do it by location OU. Thanks

# February 12, 2009 5:10 PM

yli628 said:

Yes, you have to use quest AD cmdlets and do something like

get-qadcomputer -searchroot 'whateve'...

# February 12, 2009 5:29 PM