枚举域内计算机个数vbscript脚本(没环境,没测试)
程序员文章站
2022-04-10 08:07:27
原来是微软专家的代码在这: http://www.microsoft.com/china/technet/community/scriptcenter/resources/...
原来是微软专家的代码在这:
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
上一篇: vbs 函数 获取数组字符串的最后一个LastOne 挺方便的
下一篇: 重新安装ie的一个vbs