vbScript để lấy danh sách users thuộc nhóm Administrator trên một hoặc nhiều máy tính.


'Thay C:\Temp\LocalAdminUser.txt thành tên group anh thích
'Script này chỉ lấy thông tin Administrator trên máy tính local

Dim WshNetwork
Set WshNetwork = CreateObject("WScript.Network")
strComputer = WshNetwork.ComputerName
Const ForAppending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSO.OpenTextFile("c:\temp\LocalAdminUser.txt", _
    ForAppending, True)
 
objLogFile.writeline " "
objLogFile.writeline " **************** List of Users in Local Administors Group on " & strComputer & " ****************"  
Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("group")
For Each objGroup In colGroups
    if (objGroup.Name ="Administrators") then
      For Each objUser in objGroup.Members
      objLogFile.writeline vbTab & objUser.Name
    Next
    End If 
Next    
objLogFile.Close

'Open the List of user in Administrators group
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\temp\LocalAdminUser.txt"

==========================

'Thay C:\Temp\ServerList.txt thanh Folder và Server list bạn thich
' Trong Serverlist.txt anh add nhieu PCName or ServerName
'Thay C:\Temp\LocalAdminUser.txt thanh ten group anh thíich, ket qua se duoc export vao file này.

Const ForAppending = 8
Const ForReading = 1
ServerCount = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    ("c:\temp\serverlist.txt", ForReading)
Do Until objTextFile.AtEndOfStream
    strNextLine = objTextFile.Readline
strComputer = strNextLine
'WScript.Echo "Processing " & strComputer
ProcessGroups
ServerCount = ServerCount + 1
Loop
'WScript.Echo "Computers Processed  " & ServerCount
'WScript.Quit
Sub ProcessGroups
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSO.OpenTextFile("c:\temp\LocalAdminUser.txt", _
    ForAppending, True)
 
objLogFile.writeline " "
objLogFile.writeline "**************** " & strComputer & " ****************"
Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("group")
'Ki?m tra n?u là group Administrators thì ghi vào file.
For Each objGroup In colGroups
    if (objGroup.Name ="Administrators") then
        For Each objUser in objGroup.Members
        objLogFile.writeline vbTab & objUser.Name
    Next
    End If
Next  
objLogFile.Close
End Sub
' M? file LocalAdminUser.txt lên
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\temp\LocalAdminUser.txt" 

download:https://mega.nz/#!zhg0gSqR!eghIWCscwHw7VNeUF5C_RoWqVv5XPMt4ObQvgKCcM5M
nguồn itlab.com.vn


EmoticonEmoticon