LiquidObject

Using PowerShell to copy Active Directory Group Membership

If you’ve ever needed to group membership between to AD groups you could do this one by one which while does work, what happens if you have a list with 10, 20, 30,….or even 5000+ users? To copy the membership from one group into another via PowerShell under Server 2008 is a simple two lines (plus import command).

 


Import-Module ActiveDirectory

$mymembers = Get-ADGroupMember -identity My_Source_Group_Name | Select-Object SamAccountName

foreach($i in $mymembers){Add-ADGroupMember -Identity My_Destination_Group_Name -Members $i.SamAccountName}
, ,
November 18, 2011 at 11:35 am Comments (2)