Add a user into multiple groups
-
Thursday, November 19, 2009 4:46 AM
Hi,
I would like have a comamnd or script which I can add a user accoun into multiple domain security groups.
I should be able to read the group information from a file.
Thanks in advance
Regards
Arunhi,
After runnig below command in Power shell 2.0 I am getting this error
PS C:\Arun\scripts> $groups |% {add-adprincipalgroupmembership $user $group}
The term 'add-adprincipalgroupmembership' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.
At line:1 char:43
+ $groups |% {add-adprincipalgroupmembership <<<< $user $group}
I have entered command as
1. $user = "kumar"
2. $groups = "groups.txt"
3. $groups |% {add-adprincipalgroupmembership $user $group}
I am not good in scripts, so sorry if Ia m doign any stupidity here
Regards
Arun
Arun- Edited by Vkakumar Sunday, November 22, 2009 7:42 PM
All Replies
-
Thursday, November 19, 2009 2:29 PM
Using PS V2/RSAT:
$user = "<username>"
$groups = gc groups.txt
$groups |% {add-adprincipalgroupmembership $user $group}- Proposed As Answer by Tome TanasovskiMVP Saturday, November 21, 2009 1:56 AM
-
Tuesday, November 24, 2009 2:59 AMI am looking for
1. add a user into multiple domain security groups
2. script should read group information froma txt file.
Regards
Arun -
Tuesday, November 24, 2009 3:15 AMModerator
Perhaps the last line should be:Using PS V2/RSAT:
$user = "<username>"
$groups = gc groups.txt
$groups |% {add-adprincipalgroupmembership $user $group}
$groups |% {add-adprincipalgroupmembership $user $_}
Vkakumar: Are you still having problems with add-adprincipalgroupmembership? I'll have to lookup the module name to make sure you've imported it first... -
Tuesday, November 24, 2009 4:49 AMThanks for the respose.
Yes I am still having error with 'add-adprincipalgroupmembership
The term 'add-adprincipalgroupmembership' is not recognized as a cmdlet, function, operable program, or script file. Ve
rify the term and try again.
It looks 'add-adprincipalgroupmembership not recogonising my windows Power shell 2.0
Is there any way I am import this cmdlet inot my power shell.
Regards
Arun -
Tuesday, November 24, 2009 4:51 AMI do not have a windows 2008 Domain controller in my domain. I am running only windows 2000 domain.
-
Tuesday, November 24, 2009 6:25 AMModerator
Hi Arun,
For the Active Directory module to function correctly, Windows PowerShell and the .NET Framework 3.5.1 must be installed on your Windows Server 2008 R2 or Windows 7 computer.
If you have Windows Server 2008 R2 or Windows 7 computer, run the following PowerShell command:
Import-Module ActiveDirectory
For more information, please refer to the following article:
Active Directory Administration with Windows PowerShell
http://technet.microsoft.com/en-us/library/dd378937(WS.10).aspx
Thanks.
This posting is provided "AS IS" with no warranties, and confers no rights.- Marked As Answer by Mervyn ZhangModerator Thursday, November 26, 2009 5:55 AM
-
Tuesday, November 24, 2009 12:36 PMModerator
I do not have a windows 2008 Domain controller in my domain. I am running only windows 2000 domain.
You're saying your DCs are Windows 2000? You won't be able to use the new AD cmdlets/module then. You'll have to consider either using the .NET Framework or the Quest AD cmdlets (www.quest.com/powershell) to be able to do AD administration in this case.- Marked As Answer by Mervyn ZhangModerator Thursday, November 26, 2009 5:55 AM

