枚举域内计算机个数vbscript脚本(没环境,没测试)
作者:
枚举域内计算机个数的脚本,参考了微软官方的代码,有兴趣的朋友可以参考下。
原来是微软专家的代码在这:
http://www.microsoft.com/china/technet/community/scriptcenter/resources/hey060127.mspx
我改成了全自动式的,不需要手要修改域的adsi连接字符串了,代码:
On Error Resume Next
Set objRootDSE = GetObject("LDAP://rootDSE")
strDomain = ObjRootDSE.Get("defaultNamingContext")
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://" & strDomain & "' WHERE objectCategory='computer'"
Set objRecordSet = objCommand.Execute
Wscript.Echo objRecordSet.RecordCount
http://www.microsoft.com/china/technet/community/scriptcenter/resources/hey060127.mspx
我改成了全自动式的,不需要手要修改域的adsi连接字符串了,代码:
复制代码 代码如下:
On Error Resume Next
Set objRootDSE = GetObject("LDAP://rootDSE")
strDomain = ObjRootDSE.Get("defaultNamingContext")
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://" & strDomain & "' WHERE objectCategory='computer'"
Set objRecordSet = objCommand.Execute
Wscript.Echo objRecordSet.RecordCount
您可能感兴趣的文章:
- ASP、vbscript编码模板
- ASP中一个用VBScript写的随机数类
- 利用vbscript脚本修改文件内容,此适用于自动化的操作中
- asp,VBscript语法错误,史上最全最详细最精确
- vbscript脚本编程教程2利用fso来进行文件操作
- 使用vbscript脚本在表单中进行选择的代码
- 用vbscript脚本实现返回 IP 配置数据的代码
- ASP里面令人震撼地Debug类(VBScript)
- 调试JavaScript/VBScript脚本程序(IE篇)
- JavaScript/VBScript脚本程序调试(Wscript篇)
- ASP/VBScript中CHR(0)的由来以及带来的安全问题分析
- ASP(VBScript)中整除和取余
- ASP基础知识VBScript基本元素讲解
- ASP基础入门第四篇(脚本变量、函数、过程和条件语句)