Jump to content

How To Find Out What Accounts Are In Local Admin Group


Recommended Posts

Ok I am not sure where to start with this one. I am trying to find a script that will allow me to create an output or a file or anything that will show what accounts are located in the local admin account. We do alot of network pushes and not everyone is an admin on the machine so I need to know if a particular account is in the local admins group or not. Currently I have a VBscript that I can run, using an external text file that will add a specific account to the admins group of the computer names that are list. The only thing I dont know is how many of the 500 machines have recieved the specified account into local group. Is there anyone out there that can help me with this, or point me in the right direction??

Link to comment
Share on other sites

  • Developers

Ok I am not sure where to start with this one. I am trying to find a script that will allow me to create an output or a file or anything that will show what accounts are located in the local admin account. We do alot of network pushes and not everyone is an admin on the machine so I need to know if a particular account is in the local admins group or not. Currently I have a VBscript that I can run, using an external text file that will add a specific account to the admins group of the computer names that are list. The only thing I dont know is how many of the 500 machines have recieved the specified account into local group. Is there anyone out there that can help me with this, or point me in the right direction??

if IsAdmin() then
:)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

WOO HOO I figured this one out. With a bit of searching and research I came up with this little script. I'm sure if this gets looked at enough that something can be done with the way the final information is added to the CSV file, but I am not that savy yet to come up with something of that means. Here is the code:

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:        Ben Sherrill
;
; Script Function:
;   Use CMD Prompt to run a Net Localgroups Administrators.
;~  The Using STDOUT move that data to a text file.
;   Once the text file is created use  ReadLine to get the specific users that are admins on the computer
;~  Create as CSV file for easier sorting of the computer name
; ----------------------------------------------------------------------------


#include <Constants.au3>
#include <Process.au3>
#include <File.au3>

;~ Check to see if this has already been run on the computer
If FileExists("C:\administrator.txt") Then
   Exit
EndIf
;~ FileDelete("C:\administrator.txt");used for testing purposes
; Start up the CMD Prompt
$cmd = Run(@ComSpec & "", @SystemDir, @SW_SHOW, 7)

; Write the desired commands + RETURNs to the child's STDIN
StdinWrite ($cmd, "net localgroup administrators" & @CRLF & "exit" & @CRLF)

; Loop and retrieve all data from the CMD Window
While 1
   $line = StdoutRead ($cmd)
   If @error = -1 Then ExitLoop
   $file = FileOpen("C:\administrator.txt", 1)
   FileWrite($file, $line)
   FileClose($file)
   
WEnd

; Loop and collect any error messsages from the child program
While 1
   $line = StderrRead ($cmd)
   If @error = -1 Then ExitLoop
   MsgBox(0, "STDERR read:", $line)
WEnd

; Reopen the Txt file located on the users C Drive for reading purposes
$file = FileOpen("C:\administrator.txt", 0)
$line11 = FileReadLine($file, 11)
$line12 = FileReadLine($file, 12)
$line13 = FileReadLine($file, 13)
$line14 = FileReadLine($file, 14)
$line15 = FileReadLine($file, 15)
$line16 = FileReadLine($file, 16)
$line17 = FileReadLine($file, 17)
;~ MsgBox(0,"test",$line11);testing purposes

; Now that the lines have been read and values have been given, create a CSV file on a Public Server for all IT to look at
$pc_admins = "\\server\folder\file.csv"
; Open the file on the public server for writing purposes
FileOpen($pc_admins, 1)
; Write the following Data - The Computer name  LINE11(first Admin line)- Line17  more lines could be added. Possible array here? not sure?
FileWrite($pc_admins, @CRLF & @ComputerName & "," & $line11 & "," & $line12 & "," & $line13 & "," & $line14 & "," & $line15 & "," & $line16 & "," & $line17)
; Data has been written, now close file and exit script
FileClose($pc_admins)

Exit
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...