?
Solved

Get all th user inside the poweruser and users group in all machines in the domain

Posted on 2007-10-16
1
Medium Priority
?
343 Views
Last Modified: 2010-04-16
Hi,

Get all th user inside the poweruser and users group in all machines in the domain.
Script that can get me all the users inside the "users and Powerusers group"

Regards
Sharath
0
Comment
Question by:bsharath
1 Comment
 
LVL 26

Accepted Solution

by:
Farhan Kazi earned 2000 total points
ID: 20088682
:: ================
:: READ THIS FIRST
:: ================
:: * To run this script you must have domain administrators rights.
:: * This script require "Computers.txt" file from where it will pick system names.
:: * Successful run will generate 'LocalGroupMembers.txt' file
:: * Copy and Paste following script into notepad and save it with any name having .cmd extension.
:: SCRIPT START
@ECHO OFF
SETLOCAL EnableDelayedExpansion
IF NOT EXIST Computers.txt GOTO ShowErr
FOR %%R IN (Computers.txt) DO IF %%~zR EQU 0 GOTO ShowErr
IF EXIST LocalGroupMembers.txt DEL /F /Q LocalGroupMembers.txt
FOR /F %%c in ('TYPE Computers.txt') DO (
      SET GroupName=Users
      SET Computer=%%c
      ECHO Processing: !Computer!
      PING -n 1 -w 1000 !Computer!|FIND /I "TTL" >NUL
      IF NOT ERRORLEVEL 1 (
            ECHO -------------->>LocalGroupMembers.txt
            ECHO !Computer!>>LocalGroupMembers.txt
            ECHO -------------->>LocalGroupMembers.txt
            :Again
            ECHO USERS INSIDE: !GroupName!>>LocalGroupMembers.txt
            SET Qry=WMIC /NODE:"!Computer!" PATH Win32_GroupUser WHERE ^(GroupComponent="WIN32_Group.Name=\"!GroupName!\",Domain=\"!Computer!\""^) GET PartComponent /FORMAT:CSV
            FOR /F "Tokens=5 Delims==," %%I IN ('!Qry! 2^>NUL') DO (ECHO       %%~I>>LocalGroupMembers.txt)
            ECHO.>>LocalGroupMembers.txt
            IF "!GroupName!"=="Users" SET GroupName=Power Users&Call :Again))
GOTO EndScript
:ShowErr
ECHO 'Computers.txt' file does not exist or file is empty!
:EndScript
ENDLOCAL
:: *** SCRIPT END ***

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question