This techtip handles how to copy group memberships from a single user to one or more users in your organization
. In order to accomplish this we use only the Active Directory module included in RSAT or available with Windows Server 2012.
1 |
$groups = Get-ADUser -filter {Name -like "<FirstName*LastName>"} | Get-ADPrincipalGroupMembership | foreach {Add-ADGroupMember $_ -Members $user.Name} |
In order to copy the group membership to several users, simply add a foreach-loop in the script
.
1 2 3 4 5 |
$groups = Get-ADUser -filter {Name -like "<FirstName*LastName>"} | Get-ADPrincipalGroupMembership Foreach ($user in $users) { $groups | foreach {Add-ADGroupMember $_ -Members $user.Name} } |
In the last example, the variable $users would typically be populated using the the cmdlet Get-ADUser to pull from AD based on specific criteria, like OU etc
.
This script only adds groups, it does not replace existing group memberships
2-3 How long does cialis last? epidemiological and clinical trial data..
.