我正在寻找一个vbscript
,我可以将“计算机帐户成员”中的所有组都放到文本文件中。对于“成员”用户帐户要复制到文本,我使用net user test /domain
c:\temp\testaccount.txt
&的命令。我会在几秒钟内获得所有成员或Local/Global
群组成员资格。是否有运行命令或需要脚本?
梅尔文
答案 0 :(得分:0)
这是我用于此的脚本,但是这样的操作永远不会像你的控制台命令一样快,如果这是一个问题,你可以使用run命令从脚本执行命令。 您需要知道域的LDAP路径。由于回显你最好用cscript.exe运行它。
Const ForReading = 1, ForWriting = 2, ForAppending = 8, CreateIfNeeded = true
Dim fso, filename, objConnection, objCommand, oShell, sResult, objRecordSet, oFile_out
Set fso = CreateObject("Scripting.FileSystemObject")
filename = "\\server\share\out.txt"
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "<LDAP://domain/OU=Workstations,OU=Computers,...>;;name;subtree"
Set oShell = CreateObject("Wscript.Shell")
sResult = oShell.Popup("Generating list..", 2, "Have some patience please, the list is generated")
on error resume next
Set objRecordSet = objCommand.Execute
Call CheckForError
set oFile_out = fso.OpenTextFile (filename, ForWriting, CreateIfNeeded)
Call CheckForError
While Not objRecordset.EOF
oFile_out.writeline objRecordset.Fields("name")
Wscript.Echo objRecordset.Fields("name")
objRecordset.MoveNext
Wend
'--- ---'
Sub CheckForError
if err.number <> 0 Then
msgbox("39: "&err.description)
err.clear
end if
End Sub