Ever said to yourself, "I'm not sure what computer accounts in this OU are valid"!
Well, with this script you can see when the last time a computer(in an OU) logged in.
———-COPY EVERYTHING BELOW THIS LINE———-
'This script will shut down all computers on the domain
'Created by C.E. Harden June 13 2006
On error resume next
Wscript.Echo "The output will be written to C:\oldComputers.txt"
set objADO = GetObject("LDAP://ou=workstations,ou=liverpool,dc=contoso,dc=local")
set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
set txtStream = fso.OpenTextFile("C:\oldComputers.txt", 8, True)
set objContainer = objADO
For each objChild in objContainer
user = MID(objChild.Name,4)
If DateDiff ("d",objChild.LastLogin, Now) > 180 then txtStream.WriteLine user & " —> " & DateDiff ("d",objChild.LastLogin, Now)_
& " Days since last login." & vbCrLf
———-COPY EVERYTHING ABOVE THIS LINE———-
PLEASE MAKE SURE NO WORD WRAPPING IS HAPPENING IN YOUR SCRIPT!!!
To make this script work you will need one thing!
1. You will need the OU in which your computer accounts are kept.
Edit the string LDAP://
The script will be written to the root of the c:\ drive.
*Make sure you are an administrator to run this.
This information is provided "AS IS" with no warranties expressed or implied.