Petri.co.il forums Home Forums Start Page Forums Frequently Asked Questions FAQ Member List Members List
Go Back   Petri IT Knowledgebase Forums > Windows Scripting > General Scripting
Petri.co.il is happy to award RicklesP the title of Most Valuable Member !!!
Register Calendar Calendar Search Petri IT Knowledgebase Forums Search Todays Posts Today's Posts Mark Forums Read
Notices

how to list disabled computer accounts

how to list disabled computer accounts

this thread has 4 replies and has been viewed 12952 times

Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1  
Old 17th December 2008, 15:01
tolgatt tolgatt is offline
Casual
Casual
 
 Join Date: Dec 2008
  6 month star 12 month star
 Posts: 3
 Reputation: tolgatt is on a distinguished road (10)
Red face how to list disabled computer accounts

Hello,
i need a vbscript to list all disabled computer accounts in my win 2003 active directory domain. can anyone give me a sample code.
Thanks a lot
  #2  
Old 17th December 2008, 15:09
Dumber's Avatar
Dumber Dumber is offline
Moderator
 
 Join Date: Dec 2003
  6 month star 12 month star
 Location: The Netherlands
 Posts: 8,172
 Reputation: Dumber is a splendid one to beholdDumber is a splendid one to beholdDumber is a splendid one to beholdDumber is a splendid one to beholdDumber is a splendid one to beholdDumber is a splendid one to beholdDumber is a splendid one to behold (844)
Default Re: how to list disabled computer accounts

something wrong with dsquery?
http://www.robvanderwoude.com/adshel...y_computer.txt

or is t their something wrong with the AD queries you can make via ADUC?
__________________
Marcel
Technical Consultant
Netherlands
http://www.phetios.com
http://blog.nessus.nl

MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
"No matter how secure, there is always the human factor."

"Enjoy life today, tomorrow may never come."
"If you're going through hell, keep going. ~Winston Churchill"

  #3  
Old 17th December 2008, 15:29
tolgatt tolgatt is offline
Casual
Casual
 
 Join Date: Dec 2008
  6 month star 12 month star
 Posts: 3
 Reputation: tolgatt is on a distinguished road (10)
Default Re: how to list disabled computer accounts

hello dumber thanks for reply, i want to create a script that runs everyday at 7 o clock and list me disabled computer accounts and mail them to some persons. Because of this i want to make it with scripting. How can i do it with vbscript code.i find mailing code but i couldnt find disabled account listing.
  #4  
Old 17th December 2008, 20:18
Rems's Avatar
Rems Rems is offline
Moderator
 
 Join Date: Mar 2005
  6 month star 12 month star
 Location: NL
 Posts: 2,405
 Reputation: Rems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to behold (944)
Default Re: how to list disabled computer accounts

Related thread: userAccountControl differences

You can do the same for computer accounts,
Code:
Set objRootDSE = GetObject("LDAP://rootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")

'Start the ADO connection
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection

'Set the ADO connection query strings
StartNode = strDNSDomain
SearchScope = "subtree"
FilterString = "(&(objectclass=computer)" _
             & "(userAccountControl:1.2.840.113556.1.4.803:=2))"
Attributes = "adspath"

'Create the LDAP-Query
LDAPQuery = "<LDAP://" & StartNode & ">;" & FilterString & ";" _
            & Attributes & ";" & SearchScope

objCommand.CommandText = LDAPQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False

Set objRecordSet = objCommand.Execute

If not objRecordSet.eof then 
  objRecordSet.MoveFirst
  Do Until objRecordset.EOF
    Set objItem = GetObject(objRecordSet.Fields("AdsPath").Value)
    strParentOU = Replace(objItem.parent, "LDAP://", "")

       ResultsLst = _
            ResultsLst & objItem.cn & vbTab _
             & "[" & strParentOU & "]" & vbNewLine

    Set objItem = Nothing
    objRecordSet.MoveNext
  Loop
End If


wscript.echo ResultsLst

wscript.quit
(How to query Active Directory by using a bitwise filter)


\Rems
__________________

This posting is provided "AS IS" with no warranties, and confers no rights.

__________________

** Remember to give credit where credit's due **
and leave Reputation Points for meaningful posts
  #5  
Old 18th December 2008, 10:00
tolgatt tolgatt is offline
Casual
Casual
 
 Join Date: Dec 2008
  6 month star 12 month star
 Posts: 3
 Reputation: tolgatt is on a distinguished road (10)
Thumbs up Re: how to list disabled computer accounts

thank you very much rems.
Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
All administrator accounts locked out or disabled. morganmmp Forgot Administrator Password 4 4th July 2007 18:22
XP Pro disabled all active accounts! JULES Windows 2000 Pro, XP Pro 4 7th December 2006 01:04
best practise to manage disabled email accounts? znme Exchange 2000 / 2003 1 9th August 2006 17:32
Veritas and disabled user accounts m80arm Misc 1 15th July 2005 13:17
I disabled all accounts now what do I do? smitdoggy General Security 1 20th January 2005 23:20


All times are GMT +3. The time now is 12:46.

Steel Blue 3.5.4 vBulletin Style ©2006 vBEnhanced
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
 

Valid XHTML 1.0!   Valid CSS!

Copyright 2005 Daniel Petri