PowerShell: Add bulk users in one AD group

 Add Multiple users in one AD group:


Import-Module ActiveDirectory
$grp = ‘test1‘
$comps=Get-Content C:\users.txt

$grpDN = (get-adgroup $grp).distinguishedname

foreach ($user in $users)
{ #$dns=get-aduser $user
$b=$dns.distinguishedname
Add-ADGroupMember -Identity $grpDN -member $user
}

Comments

Popular posts from this blog

Troubleshooting Netlogon Error Codes

Service Principal Names (SPNs) SetSPN Syntax (Setspn.exe)

Troubleshooting AD Active Directory Replication Error 8456 or 8457: "The source | destination server is currently rejecting replication requests"