Sponsored Links

Login Form






Lost Password?

Syndicate

Home arrow RSS Feeds
Find Old/Unused Computer Accounts In An OU Or Domain PDF Print E-mail
User Rating: / 1
PoorBest 
Written by Cheyenne Harden   
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

Dim objADO
Dim objContainer
Dim objChild
Dim User

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")
fso.DeleteFile ("C:\oldComputers.txt")
set txtStream = fso.OpenTextFile("C:\oldComputers.txt", 8, True)
txtStream.WriteLine vbCrLf
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
 Next

msgbox "Done..."
WshShell.run "C:\oldComputers.txt"




----------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://
(e.g., 'LDAP://OU=workstations,OU=boston,DC=contoso,DC=com')

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.

Comments
Add New
David Gaddy  - Network Admin.   |72.250.228.187 |24-04-2008 16:27:18

'This script will shut down all computers on
the domain
'Created by C.E. Harden June 13 2006



Where
in the script does it shutdown all the computers?
Write comment
Name:
Email:
 
Title:
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 
Tag it:
Delicious
Furl it!
Spurl
digg
YahooMyWeb
< Prev   Next >
 

Google Search

Google