Localgroup Administrators
Posted: 10 Mar 2016 06:19
I have script that will collect members of local server administrator group. But however i need some help on the output method. can someone assist me please
script
output
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
admins are ASIAPACIFIC\Domain Admins ASIAPACIFIC\user2 hpadmin hpdisabled user1
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
desire output
admins are;
ASIAPACIFIC\Domain Admins
ASIAPACIFIC\user2
hpadmin
hpdisabled
user1
script
Code: Select all
@ECHO OFF
SETLOCAL
SET "admins="
SET "prev="
FOR /f "delims=" %%A IN ('net localgroup administrators') DO (
CALL SET "admins=%%admins%% %%prev%%"
SET "prev=%%A"
)
SET admins=%admins:*- =%
ECHO admins are %admins%
GOTO :EOF
output
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
admins are ASIAPACIFIC\Domain Admins ASIAPACIFIC\user2 hpadmin hpdisabled user1
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
desire output
admins are;
ASIAPACIFIC\Domain Admins
ASIAPACIFIC\user2
hpadmin
hpdisabled
user1