Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Script for last reboot

Avatar of tw525
tw525Flag for United States of America asked on
VB Script
7 Comments1 Solution1059 ViewsLast Modified:
I have a great script I found to reboot all the machines within a specific OU.

JeremyW posted this wonderful vbs script on Petri forums to force reboots:

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

'--- change the DN to where you want to start your search ---
objCommand.CommandText = _
"<LDAP://ou=workstations,ou=corp,dc=domain,dc=com>;" & _
"(objectCategory=computer);distinguishedName,name; subtree"

Set objRecordSet = objCommand.Execute

While Not objRecordSet.EOF

RestartComputer objRecordSet.Fields("Name")



Sub RestartComputer(strComputer)

set objShell = CreateObject("WScript.Shell") 
objShell.Run "shutdown -s -t 0 -f -m \\" & strComputer

End Sub  

So now I'm looking to alter this script to again look inside a specific OU and report back the last reboot time for every computer within that OU.  Just a pop up with the info would be fine.  Can anyone help me alter this script to get the output I'm looking for?  (Or create a new script if that's easier)