This by request Vbs script will return the total number of users found in the specified domain.
Note: Change DomainName to your AD domain name.
Vbs Script:
Const Ads_Scope_SubTree = 2
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 Name From 'LDAP://DC = DomainName, DC = Com' Where objectCategory = 'Person'"
Set objRecordSet = objCommand.Execute
MsgBox "Total Number Of Users Found : " & objRecordSet.RecordCount
Original Post
Note: Change DomainName to your AD domain name.
Vbs Script:
Const Ads_Scope_SubTree = 2
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 Name From 'LDAP://DC = DomainName, DC = Com' Where objectCategory = 'Person'"
Set objRecordSet = objCommand.Execute
MsgBox "Total Number Of Users Found : " & objRecordSet.RecordCount
Original Post
No comments:
Post a Comment