Home > Software design >  How to add a user to 80 Active Directory groups
How to add a user to 80 Active Directory groups

Time:10-05

I can pull the list of groups using this this snipppet:

Get-ADGroup -Filter {name -like "*.ABC*"}

How can I add a user to the returned groups?

CodePudding user response:

You could push the results from the command in your question to a variable and then run a foreach loop that will add the member for each group within the variable.

$groups = Get-ADGroup -Filter {name -like "*.ABC*"}

foreach ($group in $groups){
  Add-ADGroupMember -Identity $Group -Members User1
}
  • Related