Localgroup Administrators

Discussion in 'Software' started by kethies, Mar 16, 2016.

  1. kethies

    kethies Private E-2

    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

    Code:
    @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
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds