none
How to Read the "text file and csv file" through powershell Scripts RRS feed

  • Question

  • Hi All

    i need to add a multiple users in a particular Group through powershell Script how to read the text and CSV files in powershell

    am completly new to Powershell scripts any one pls respond ASAP.with step by step process pls

    Regards:

    Rajeshreddy.k

    Tuesday, June 17, 2014 7:25 AM

All replies

  • Hi Rajeshreddy.k,

    To add multiple users to one group, I wouldn't use a .csv file since the only value you need from a list is the users to be added.

    To start create a list of users that should be added to the group, import this list in a variable called $users, the group distinguishedName in a variable called $Group and simply call the ActiveDirectory cmdlet Add-GroupMember.

    $Users = Get-Content -Path 'C:\ListOfUsernames.txt'
    $Group = 'CN=MyGroup,OU=MyOrg,DC=domain,DC=lcl'
    Add-ADGroupMember -Identity $Group -Members $Users

    Tuesday, June 17, 2014 7:39 AM