New_ADUser script RRS feed

  • Question

  • Hi

    I have written a script to add new ad users from a csv file and after a few tries now have it working. I'm also trying to add these users to groups in the same way. My csv file contains a column called group and the required groups are added in the format of "Group,Group2,Group3". The code is below:

    Import-Csv -Path UserAccounts.csv | ForEach-Object {
    $SAM = $_.user
    $Group = $
    $Groups = $Group.split(",")
    foreach($l in $groups){
    Add-ADGroupMember -Identity $l -Member $SAM

    When this runs it adds users to any groups that have a scope of Universal, but errors with Global or Domain Local with "ADGroupMember : Cannot find an object with identity: '"Group' under: 'DC=domain,DC=com'."

    I'm not sure what I need to change? If I run add-adgroupmember from the cmd line it works for any group.


    Monday, February 10, 2014 5:20 PM


All replies