Add usernames to the power user groups

Dear,
I need to add 200 usernames as part of power users group, each user name should be added in the power users group for his computer only, in summary suppose I have the following:
username1      computer1
username2      computer2
username3      computer3
.
.
Username100  computer100
I need to add username1 in the powerusers group of computer1
add username2 in the powerusers group of computer2
and so on, please how to accomplish this task?
LVL 1
mahmoud_2008Asked:
Who is Participating?
 
Henrik JohanssonConnect With a Mentor Systems engineerCommented:
One way to accomplish the task is to let a script loop through textfile/list with username/computername and use psexec to execute 'net localgroup' remote.
http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

@echo off
for /F "tokens=1,2" %%a in (list.txt) do psexec \\%%b net localgroup "power users" %USERDOMAIN%\%%a /add

Open in new window

0
 
wpathanConnect With a Mentor Commented:
you can create a batch file and share it on a common folder or make it run through a logon script, use the following commands.
Replace the YourDomain with name of your domain and Domain Users with
%username%

Hope this helps.
net localgroup "Power Users" "YourDomain\domain users" /add
 
net localgroup "power users" "Yourdomain\%username%" /add

Open in new window

0
 
mickeyfanCommented:
Try

Net Localgroup Power USers "Domain_Name\User" /Add
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
pankaj0079Commented:
As using ur given example
username1      computer1

right click my computer-manage-local user and groups

create username1 then in groups open power user groups
click on add, type username or click on advanced then click find now
select username1-ok

now it become power user
0
 
mfhorizonCommented:
log in using network administrator to the user1's pc,
go to control panel > user accounts
on USERS tab click ADD
select user name and domain or search using BROWSE button

Once completed the user will be shown in the USERS tab on the userAccounts screen.
select the newly added user, click PROPERTIES button
select GROUP MEMBERSHIP tab, select 'OTHERS' radio button and choose POWER USER from the dropdown combo.

I think you need to repeat this process on every user's pc.

Good Luck
0
 
mahmoud_2008Author Commented:
Dear wpathan,mickyfan:
Your script will add the user for all PCs, the issue is that each user will be added to the power users group of his computer only.

Dear pankaj0079, mfhorizon:
This is a manual approach and I need an automatic script to accomplish this.
  Regards
0
 
wpathanCommented:
My script will not add all the users to power users.
If you run this script as a logon script it will add the currently logged on user in the power users group and that too on that pc only.
Give it a try in two or three pcs.
0
 
mahmoud_2008Author Commented:
Hi henjoh09,
I did a test file called  list.txt   with the following format  
username1/computre1
username2/computer2
username3/computer3
as test.vbs

copy the code and change   %USERDOMAIN%  with mydomain
   and (list.txt)    with c:\list.txt

then issue the command:
c:\test.vbs   itdisplay an error in line 2,5
0
 
mahmoud_2008Author Commented:
Wpathan,
I run your script as a logon script through group policy but it display an error because it needs to run as administrator privilages.
 How to do this?
0
 
Henrik JohanssonSystems engineerCommented:
%USERDOMAIN% environment variable shall not nead to be changed. It will be parsed by system automatically.

The format of file in sample of http:#24121755 nead to be "user computer" (space or tab separated as described in question). To get another separator like /, it's done with delims option as shown in snippet below.
Sorry for the confusion when I wrote username/computername in previous post as it wasn't ment to be the syntax of the file.

The error message is caused by you tried to run the script as a vbs instead of correct batch extension (bat or cmd).
Save the codesnippet as bulkpowerusers.cmd (or *.bat).

@echo off
for /F "delims=/ tokens=1,2" %%a in (c:\list.txt) do psexec \\%%b net localgroup "power users" %USERDOMAIN%\%%a /add

Open in new window

0
 
mahmoud_2008Author Commented:
Thanks Guys, I am splitting the points between you since both solutions are working.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.