add user(s) from CSV file 1 to Adgroups from CSV file 2

add user(s) from CSV file 1 to Adgroups from CSV file 2 till end of file

How can I make a script from this line with above wish:

Add-ADGroupMember -Identity “groupname” -Members “username”

 

I’ve moved this to general Q&A, as it was certainly less like website feedback.

What have you tried so far, beyond the line to get group members? Have you ever output anything to a file in PowerShell?

To get you started you should read the help for at least the following cmdlets:
Import-Csv,
Foreach-Object,
Add-ADPrincipalGroupMembership
and maybe
Select-Object,
about_Foreach
and
Add-ADGroupMember.
You should always read the COMPLETE help of the cmdlets you’re about to use … including all examples! :wink:

If you’re iterating through two csv’s, you might want to use a nested foreach() setup. One foreach to go through each user, then another foreach to add that specific user to a your list of AD groups. If you read the links that Olaf posted, I’m sure you’ll be able to start writing something on your own and ask for more specific help as needed.