Forum Discussion
sofo-83
Mar 30, 2022Copper Contributor
add just one user to many groups
Hi
please help me to make a script in PowerShell to add just one user to many groups
- Did this work out for you?
- sofo-83Copper Contributor
Thanks a lot
is the group name must be as a string (name) or should I bring the object ID? Harm_VeenstraThe name of the group as you see it in Active Directory, Display Name I guess. Let me know if it worked out for you, you can mark my answer as solution to mark it as solved if it does
sofo-83 You could use this one:
$Groups = @("group1","group2","..."groupN") ForEach ($Group in $Groups) {Add-ADPrincipalGroupMembership <username> -MemberOf $Group}
(https://community.spiceworks.com/topic/2128061-powershell-adding-a-single-user-to-multiple-groups, more examples there)