Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.

Answered 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
    Arun

     

    hi,

    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
     
     Proposed

    Using PS V2/RSAT:

    $user = "<username>"
    $groups = gc groups.txt
    $groups |% {add-adprincipalgroupmembership $user $group}

  • Tuesday, November 24, 2009 2:59 AM
     
     
    I 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 AM
    Moderator
     
     

    Using PS V2/RSAT:

    $user = "<username>"
    $groups = gc groups.txt
    $groups |% {add-adprincipalgroupmembership $user $group}

    Perhaps the last line should be:
    $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 AM
     
     
    Thanks 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 AM
     
     
    I do not have a windows 2008 Domain controller in my domain. I am running only windows 2000 domain.
  • Tuesday, November 24, 2009 6:25 AM
    Moderator
     
     Answered
    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.
  • Tuesday, November 24, 2009 12:36 PM
    Moderator
     
     Answered
    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.