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
}