Saturday, 27 February 2021

How to add single user in more than 100 distribution groups powershell?

 How to add a single user in more than 100 distribution groups Powershell?



$groups = 'Group1','Group2','Group3','Group4'

foreach($group in $groups){

    Add-ADGroupMember -Identity $group -Members "Username"


Via text file format



$groups = Get-Content C:\Users\Administrator\Desktop\grouplist.txt

foreach($group in $groups){

    Add-ADGroupMember -Identity $group -Members "username"






No comments:

Post a Comment