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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

NVITEnd-user supportCommented:
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?
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
pnadonCommented:
SolarWinds® VoIP and Network Quality Manager(VNQM)

WAN and VoIP monitoring tools that can help with troubleshooting via an intuitive web interface. Review quality of service data, including jitter, latency, packet loss, and MOS. Troubleshoot call performance and correlate call issues with WAN performance for Cisco and Avaya calls

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 ...
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.
ivan rosaAuthor Commented:
does anybody know a batch script solution to solve this question?
NVITEnd-user supportCommented:
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

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
NVITEnd-user supportCommented:
See possible .bat solution ID: 41140764
ivan rosaAuthor Commented:
I like it!!!! one line solution. I can read it and understand it, like good old English!!!
NVITEnd-user supportCommented:
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

ivan rosaAuthor Commented:
wow! I can't wait test this out tomorrow! you are a genius sir
ivan rosaAuthor Commented:
noted sir tks!
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.