枚舉域內計算機個數(shù)vbscript腳本(沒環(huán)境,沒測試)
更新時間:2009年10月20日 22:08:01 作者:
枚舉域內計算機個數(shù)的腳本,參考了微軟官方的代碼,有興趣的朋友可以參考下。
原來是微軟專家的代碼在這:
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寫的隨機數(shù)類
- 利用vbscript腳本修改文件內容,此適用于自動化的操作中
- asp,VBscript語法錯誤,史上最全最詳細最精確
- vbscript腳本編程教程2利用fso來進行文件操作
- 使用vbscript腳本在表單中進行選擇的代碼
- 用vbscript腳本實現(xiàn)返回 IP 配置數(shù)據(jù)的代碼
- ASP里面令人震撼地Debug類(VBScript)
- 調試JavaScript/VBScript腳本程序(IE篇)
- JavaScript/VBScript腳本程序調試(Wscript篇)
- ASP/VBScript中CHR(0)的由來以及帶來的安全問題分析
- ASP(VBScript)中整除和取余
- ASP基礎知識VBScript基本元素講解
- ASP基礎入門第四篇(腳本變量、函數(shù)、過程和條件語句)
相關文章
VBS教程:VBscript語句-ExecuteGlobal 語句
VBS教程:VBscript語句-ExecuteGlobal 語句...2006-11-11VBS教程:函數(shù)-ScriptEngineMinorVersion 函數(shù)
VBS教程:函數(shù)-ScriptEngineMinorVersion 函數(shù)...2006-11-11