Kae Travis

Move or Copy Active Directory Users

There are many occasions where I need to move or copy Active Directory users from one group to another. Usually this occurs when an application has been updated to a new version, and we need to migrate users from the old version to the new version.

If it’s an upgrade of an App-V package with uniquely named shortcuts we may wish to copy users from one AD group to another so that the users can test the old and new versions side by side. However if it’s a local installation (perhaps an MSI or a setup.exe) we would probably want to move users from one AD group to another.

Move or Copy Active Directory Users

This is a simple PowerShell script to either copy AD users or move AD users from one AD group to another:

Move AD Users

$sourceADGroupName = "example 1"
$targetADGroupName = "example 2"
Get-ADGroupMember $sourceADGroupName | ForEach-Object {
Add-ADGroupMember -Identity $targetADGroupName -Members $_ -Confirm:$false
Remove-ADGroupMember -Identity $sourceADGroupName -Members $_ -Confirm:$false
}

Copy AD Users

$sourceADGroupName = "example 1"
$targetADGroupName = "example 2"
Get-ADGroupMember $sourceADGroupName | ForEach-Object {
Add-ADGroupMember -Identity $targetADGroupName -Members $_ -Confirm:$false
}

 

Move or Copy Active Directory Users
Move or Copy Active Directory Users

Leave a Reply