Write members of local administrator group to a text file

Ever wanted to pull a list of all members of a computers local administrator group without physically touching a computer?

Here is how you do it:

Create yourself an emtpy batch (.BAT) file.

Edit the batch file with so it contains the following commands:


REM --------------------------------------------------------------

net localgroup administrators >
c:\"text file of your choice"

REM --------------------------------------------------------------

Set the script to run at login. The next time a user logs in, the data will be recorded to your file.

Now lets get a little bit creative with this script. Lets say you have an Active Directory domain and you need to get this iformation off of several hundred computers and don't want to physically touch each computer. Try this:

First make sure you have some place you can store all of the data to be generated (i.e fileserver). Set permissions as needed.

Create yourself an emtpy batch file.

Edit the batch file to contain the following commands:


REM ------------------------------------------------------------------------

@echo off

REM This will create the folder with the computer name on the server you specify

mkdir \\"server name"\%computername%

REM Retrieve user data from administrators group and copy to the appropriate folder

net localgroup administrators >
\\"server name"\%computername%\"your filename.txt"

EXIT

REM -------------------------------------------------------------------------

Set up a Group Policy Object to run this batch file at login and watch the data pour into your data repository.

Comments
BlogCFC was created by Raymond Camden. This blog is running version 5.9.003.
THE COMPUTER WIZARDS is hosted by Integration, LLC
Contents of this site are solely the opinion of the Authors (Sid Wing/Jeff Taylor)
and do not reflect the opinions of ILLC or any of its affiliates.
All Contents are Copyright, The Computer Wizards, © 2008