batch script for local admins

Hello colleagues,

I was wondering if anybody can help me to create a batch script so I can scan a pclist.txt and provide me with a .csv  output like so

Capture.JPG
I know this will do it individually
net localgroup groupname

Open in new window


I also know findstr might will also be involved I just don't know how to apply it in bulk, but this is my guess if you know something better, I'm all ears!

thanks for looking
LVL 3
ivan rosaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITCommented:
You want each local admin user in it's own column? I don't see why. Or, should that be each localgroup in it's own column?
0
ivan rosaAuthor Commented:
They don't need to be in separate columns, if it makes it easier, you could add them one after the other in the same Column
0
pnadonCommented:
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

ivan rosaAuthor Commented:
I've requested that this question be deleted for the following reason:

I asked for a batch script only one answer was provided in Powershell ...
0
jmcgOwnerCommented:
I think you should either have accepted pnadon's answer #41085325 suggesting Sitaram's Powershell script or continued to interact, to refine to your requirements, to better explain what you wanted to do and why the offered answers aren't going to work for you... Most experts won't continue to offer suggestions when they see that a question appears to have a good answer. Once a question goes dormant for 5 days or so, it's highly unlikely to attract new interest.
0
ivan rosaAuthor Commented:
does anybody know a batch script solution to solve this question?
0
NVITCommented:
Here's a crude solution using psexec. Not exactly what you want but has all the data:

 1. Make a stns.txt file containing names of stations. e.g.
stn1
stn2

Open in new window

2. Make a .bat of this. Results are sent to file results.txt:
for /f %%a in (stns.txt) do psexec \\%%a cmd /c (echo %%computername%%& net localgroup administrators >>test.txt)

Open in new window

results.txt
STN1
Alias name     administrators
Comment        Administrators have complete and unrestricted access to the computer/domain

Members

-------------------------------------------------------------------------------
Administrator
masterofstn2
DOMAIN\Domain Admins
The command completed successfully.

STN2
Alias name     administrators
Comment        Administrators have complete and unrestricted access to the computer/domain

Members

-------------------------------------------------------------------------------
Administrator
masterofstn2
DOMAIN\Domain Admins
The command completed successfully.

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NVITCommented:
See possible .bat solution ID: 41140764
0
ivan rosaAuthor Commented:
I like it!!!! one line solution. I can read it and understand it, like good old English!!!
0
NVITCommented:
EDIT TO  ID: 41140764:

Make findfilter.txt:
^Alias name
^Comment
^Members$
^$
^The command completed

Open in new window


Revise step 2 .bat file to this:
REM Find local admins on stations. Results are sent to file results.txt:
for /f %%a in (stns.txt) do psexec \\%%a cmd /c (echo %%computername%%& net localgroup administrators >>results.txt)

REM Clean up results.txt. Send output to resultsfinal.txt
findstr /r /v /g:findfilter.txt results.txt>resultsfinal.txt

Open in new window

0
ivan rosaAuthor Commented:
wow! I can't wait test this out tomorrow! you are a genius sir
0
ivan rosaAuthor Commented:
noted sir tks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.