Quantcast
Channel: Directory Services forum
Viewing all articles
Browse latest Browse all 31638

Mass add-groupmember from a CSV

$
0
0

Hi, 

I have a very long list of users that need to added to a group. I'm stuck. 

The script works if i have the Samaccountname. but i got the full name. Can I convert the full name to a Samaccountname?

File format is 

User,Group
test test,SG-P-Administratie Administratief medewerker
Esther Hermsen,SG-P-Administratie Administratief medewerker

So far i got this.

Import-Module ActiveDirectory #Import CSV $csv = @() $csv = Import-Csv -Path "C:\Scripts\Bulk_user_group.csv" #Loop through all items in the CSV ForEach ($item In $csv) { #add the user to the group add-adgroupmember -identity $item.group -member $item.user Write-Host "User $($item.User) Added to $($item.group)!

}


Does anyone have a Idea on how to fix this?

I hope somebody can help me. otherwise i need to covert over 250 users manually.
There should be a solution but I can't get it to work. 

Regards Mark



Viewing all articles
Browse latest Browse all 31638

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>