![]() |
|
|
|||||||
| Petri.co.il is happy to award auglan the title of Most Valuable Member !!! |
| Register | Calendar |
Search |
Today's Posts |
Mark Forums Read |
| Notices |
|
|
how to list disabled computer accountsthis thread has 4 replies and has been viewed 10785 times
|
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||||||
|
||||||||
|
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
|
||||||||||
|
||||||||||
|
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 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. |
|
#3
|
||||||||
|
||||||||
|
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
|
||||||||||
|
||||||||||
|
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
\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
|
||||||||
|
||||||||
|
thank you very much rems.
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
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 |