欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

枚举域内计算机个数vbscript脚本(没环境,没测试)

程序员文章站 2022-07-04 20:27:19
原来是微软专家的代码在这: 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