displays all computer names and numbers in the current domain
Copy Code code as follows:
Const Ads_scope_subtree = 2
Set objRootDSE = GetObject ("LDAP://rootDSE")
Strdomain = Objrootdse.get ("defaultNamingContext")
Set objconnection = CreateObject ("ADODB. Connection ")
Set objcommand = CreateObject ("Adodb.command")
Objconnection.provider = "Adsdsoobject"
Objconnection.open "Active Directory Provider"
Set objcommand.activeconnection = objconnection
objCommand.Properties ("Page Size") = 1000
objCommand.Properties ("searchscope") = Ads_scope_subtree
Objcommand.commandtext = "SELECT * from ' ldap://" & Strdomain & "' WHERE objectcategory= ' computer '"
Set objRecordSet = Objcommand.execute
Objrecordset.movefirst
Do Until objrecordset.eof
WScript.Echo Objrecordset.fields ("ADsPath"). Value
Objrecordset.movenext
Loop
WScript.Echo ""
WScript.Echo "Total Computer:" &objrecordset.recordcount
Displays the name and number of all users in the current domain
Copy Code code as follows:
Const ads_scope_subtree = 2
Set objRootDSE = GetObject ("LDAP://rootDSE")
Strdomain = Objrootdse.get ("defaultNamingContext")
Set objconnection = CreateObject ("ADODB. Connection ")
Set objcommand = CreateObject (" ADODB. Command ")
Objconnection.provider =" Adsdsoobject "
Objconnection.open" Active Directory Provider "
Set obj Command.activeconnection = objconnection
objCommand.Properties ("Page Size") = 1000
objCommand.Properties ("Sea Rchscope ") = ads_scope_subtree
Objcommand.commandtext =" select * from ' ldap://"& Strdomain &" ' WHERE obje ctcategory= ' user '
Set objrecordset = Objcommand.execute
Objrecordset.movefirst
do Until Objrecordset.eo F
WScript.Echo Objrecordset.fields ("ADsPath"). Value
Objrecordset.movenext
Loop
WScript.Echo "
WScript.Echo" Total User: "&objrecordset.reco Rdcount