Results 1 to 11 of 11

Thread: Getting a list of users in global and local groups.

  1. #1
    Joe Guest

    Getting a list of users in global and local groups.

    I found this batch file on a newsgroup a while back, I'm trying to get a
    text file that shows all the users I have in my domain groups. It keeps on
    giving me a message of something like "group not found" (I'm not near a dc
    to give the exact error) I noted the line numbers in this string.

    Any ideas how to make this work ?

    Line 1@echo off
    Line 2 if exist c:\Groups.txt del c:\Groups.txt
    Line 3 for /F "tokens=*" %%* in ('net localgroup ^| find "*"') do call :Sub
    %%*
    Line 4 for /F "tokens=*" %%* in ('net groups /domain ^| find "*"') do call
    :Sub %%*
    Line 5 goto :eof
    Line 6 :sub
    Line 7 set name=%*
    Line 8 net group "%name:~1%" | find /i /v "comment" | find /i /v "members" |
    find /i /v "--------------" | find /i /v "completed successfully" >>
    c:\Groups.txt


  2. #2
    Pegasus \(MVP\) Guest

    Re: Getting a list of users in global and local groups.


    "Joe" <joe@charter.net> wrote in message
    news:1F14D37A-93AA-47AE-A7D1-7A7BD22EE975@microsoft.com...
    >I found this batch file on a newsgroup a while back, I'm trying to get a
    >text file that shows all the users I have in my domain groups. It keeps on
    >giving me a message of something like "group not found" (I'm not near a dc
    >to give the exact error) I noted the line numbers in this string.
    >
    > Any ideas how to make this work ?
    >
    > Line 1@echo off
    > Line 2 if exist c:\Groups.txt del c:\Groups.txt
    > Line 3 for /F "tokens=*" %%* in ('net localgroup ^| find "*"') do call
    > :Sub %%*
    > Line 4 for /F "tokens=*" %%* in ('net groups /domain ^| find "*"') do call
    > :Sub %%*
    > Line 5 goto :eof
    > Line 6 :sub
    > Line 7 set name=%*
    > Line 8 net group "%name:~1%" | find /i /v "comment" | find /i /v "members"
    > | find /i /v "--------------" | find /i /v "completed successfully" >>
    > c:\Groups.txt


    This looks like a batch file I designed for someone else
    last November. It works quite nicely, provided that you
    don't have any "poison" characters in your group names.
    To see for yourself, insert these lines immediately after
    Line 7 and report the result:

    echo Name=%name%
    pause



  3. #3
    cmail0925@gmail.com Guest

    Re: Getting a list of users in global and local groups.

    It displays groups when adding the echo, however, it still responds
    with "the group name can not be found". Additionally, the groups.txt
    file is created, but nothing is written to it.


  4. #4
    Pegasus \(MVP\) Guest

    Re: Getting a list of users in global and local groups.


    <cmail0925@gmail.com> wrote in message
    news:1188486846.404952.64320@k79g2000hse.googlegroups.com...
    > It displays groups when adding the echo, however, it still responds
    > with "the group name can not be found". Additionally, the groups.txt
    > file is created, but nothing is written to it.
    >


    Are you "Joe"?

    Post the exact batch file you're using!



  5. #5
    Joe Guest

    Re: Getting a list of users in global and local groups.

    Yes, that is me at work..

    I posted the exact batch file in the original thread. I'm applying it on a
    Windows 2003 dc with the default groups.
    I did create a a test group and it echoed through along with all the others
    with the echo command you gave me.
    However, I just get a blank file in the root directory.


    "Pegasus (MVP)" <I.can@fly.com> wrote in message
    news:OetDfpz6HHA.5844@TK2MSFTNGP02.phx.gbl...
    >
    > <cmail0925@gmail.com> wrote in message
    > news:1188486846.404952.64320@k79g2000hse.googlegroups.com...
    >> It displays groups when adding the echo, however, it still responds
    >> with "the group name can not be found". Additionally, the groups.txt
    >> file is created, but nothing is written to it.
    >>

    >
    > Are you "Joe"?
    >
    > Post the exact batch file you're using!
    >



  6. #6
    Pegasus \(MVP\) Guest

    Re: Getting a list of users in global and local groups.

    I beg to disagree. Your original post had the string
    "Line 1", "Line 2" at the beginning of each line. This
    batch file could not possibly work. I've been in this
    game for too long to consider something such as
    "The batch file looked like this". I need the real thing!


    "Joe" <joe@charter.net> wrote in message
    news:CDB2E2E6-9122-4E7F-83F5-7C309E8CFA70@microsoft.com...
    > Yes, that is me at work..
    >
    > I posted the exact batch file in the original thread. I'm applying it on a
    > Windows 2003 dc with the default groups.
    > I did create a a test group and it echoed through along with all the
    > others with the echo command you gave me.
    > However, I just get a blank file in the root directory.
    >
    >
    > "Pegasus (MVP)" <I.can@fly.com> wrote in message
    > news:OetDfpz6HHA.5844@TK2MSFTNGP02.phx.gbl...
    >>
    >> <cmail0925@gmail.com> wrote in message
    >> news:1188486846.404952.64320@k79g2000hse.googlegroups.com...
    >>> It displays groups when adding the echo, however, it still responds
    >>> with "the group name can not be found". Additionally, the groups.txt
    >>> file is created, but nothing is written to it.
    >>>

    >>
    >> Are you "Joe"?
    >>
    >> Post the exact batch file you're using!
    >>

    >




  7. #7
    cmail0925@gmail.com Guest

    Re: Getting a list of users in global and local groups.

    Here you go...

    @echo off
    if exist c:\Groups.txt del c:\Groups.txt
    for /F "tokens=*" %%* in ('net localgroup ^| find "*"') do call :Sub %
    %*
    for /F "tokens=*" %%* in ('net groups /domain ^| find "*"') do
    call :Sub %%*
    goto :eof
    :sub
    set name=%*
    echo Name=%name%
    net group "%name:~1%" | find /i /v "comment" | find /i /v "members" |
    find /i /v "--------------" | find /i /v "completed successfully" >> c:
    \Groups.txt


  8. #8
    Pegasus \(MVP\) Guest

    Re: Getting a list of users in global and local groups.

    The batch file you posted works very nicely on my machines.
    Here is a modified version you could try. You must remove
    the # characters that marks the start of each line.
    #@echo off
    #if exist c:\Groups.txt del c:\Groups.txt
    #set parm=Localgroup
    #for /F "tokens=*" %%* in ('net localgroup ^| find "*"') do call :Sub %%*
    #set parm=Group
    #for /F "tokens=*" %%* in ('net groups /domain ^| find "*"') do call :Sub
    %%*
    #notepad c:\Groups.txt
    #goto :eof
    #
    #:Sub
    #set name=%*
    #echo Group name: %name%
    #echo %parm% name: %name:~1% >> c:\Groups.txt
    #net %parm% "%name:~1%" | find /i /v "completed successfully" | more +6 >>
    c:\Groups.txt

    If this version still does not work then you must post the
    output generated by the following commands:
    net localgroup
    net localgroup administrators
    net groups /domain
    net groups /domain "domain admins"


    <cmail0925@gmail.com> wrote in message
    news:1188572920.392066.284600@r34g2000hsd.googlegroups.com...
    > Here you go...
    >
    > @echo off
    > if exist c:\Groups.txt del c:\Groups.txt
    > for /F "tokens=*" %%* in ('net localgroup ^| find "*"') do call :Sub %
    > %*
    > for /F "tokens=*" %%* in ('net groups /domain ^| find "*"') do
    > call :Sub %%*
    > goto :eof
    > :sub
    > set name=%*
    > echo Name=%name%
    > net group "%name:~1%" | find /i /v "comment" | find /i /v "members" |
    > find /i /v "--------------" | find /i /v "completed successfully" >> c:
    > \Groups.txt
    >




  9. #9
    Joe Guest

    Re: Getting a list of users in global and local groups.

    Ok, I'll try this on Tuesday when I'm back at work. Thanks!


    "Pegasus (MVP)" <I.can@fly.com> wrote in message
    news:%23n53Nm%236HHA.484@TK2MSFTNGP06.phx.gbl...
    > The batch file you posted works very nicely on my machines.
    > Here is a modified version you could try. You must remove
    > the # characters that marks the start of each line.
    > #@echo off
    > #if exist c:\Groups.txt del c:\Groups.txt
    > #set parm=Localgroup
    > #for /F "tokens=*" %%* in ('net localgroup ^| find "*"') do call :Sub %%*
    > #set parm=Group
    > #for /F "tokens=*" %%* in ('net groups /domain ^| find "*"') do call :Sub
    > %%*
    > #notepad c:\Groups.txt
    > #goto :eof
    > #
    > #:Sub
    > #set name=%*
    > #echo Group name: %name%
    > #echo %parm% name: %name:~1% >> c:\Groups.txt
    > #net %parm% "%name:~1%" | find /i /v "completed successfully" | more +6 >>
    > c:\Groups.txt
    >
    > If this version still does not work then you must post the
    > output generated by the following commands:
    > net localgroup
    > net localgroup administrators
    > net groups /domain
    > net groups /domain "domain admins"
    >
    >
    > <cmail0925@gmail.com> wrote in message
    > news:1188572920.392066.284600@r34g2000hsd.googlegroups.com...
    >> Here you go...
    >>
    >> @echo off
    >> if exist c:\Groups.txt del c:\Groups.txt
    >> for /F "tokens=*" %%* in ('net localgroup ^| find "*"') do call :Sub %
    >> %*
    >> for /F "tokens=*" %%* in ('net groups /domain ^| find "*"') do
    >> call :Sub %%*
    >> goto :eof
    >> :sub
    >> set name=%*
    >> echo Name=%name%
    >> net group "%name:~1%" | find /i /v "comment" | find /i /v "members" |
    >> find /i /v "--------------" | find /i /v "completed successfully" >> c:
    >> \Groups.txt
    >>

    >
    >



  10. #10
    cmail0925@gmail.com Guest

    Re: Getting a list of users in global and local groups.

    I ran the script, but all that pops up is one local group called
    _vmware_


  11. #11
    Pegasus \(MVP\) Guest

    Re: Getting a list of users in global and local groups.

    <cmail0925@gmail.com> wrote in message
    news:1189031270.652666.278240@k79g2000hse.googlegroups.com...
    >I ran the script, but all that pops up is one local group called
    > _vmware_
    >


    I cannot help you any further unless you're prepared to run
    the diagnostic stuff I mentioned in my last reply.



Similar Threads

  1. Replies: 4
    Last Post: 26-02-2009, 02:21 AM
  2. Replies: 1
    Last Post: 09-10-2007, 02:23 AM
  3. Missing Local Users and Groups
    By pushpendra in forum Small Business Server
    Replies: 3
    Last Post: 14-02-2007, 10:30 AM
  4. Missing - Local USers and Groups
    By Susan Bradley in forum Windows XP Support
    Replies: 2
    Last Post: 03-10-2005, 03:45 PM
  5. Replies: 1
    Last Post: 10-06-2005, 07:52 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,710,857,135.35553 seconds with 17 queries