# Powershell Script to COPY AD User accounts from one group to another
# Usage Launch a powershell command window in a user context with permissions to the change the AD
# .\<path>\CopyUsersToUpdateAppGroup.ps1 <OldGroupName> <NewGroupName>
$split = $args.split(" ")
$OldGroupName = $split[0]
$NewGroupName = $split[1]
$Domain = "FQDN of AD Domain Goes Here"
$UserNames = Get-ADGroupMember $OldGroupName | Get-ADUser | Select-Object `
-ExpandProperty SamAccountName
# Add each user to the newly created AD group
ForEach ($UserName in $UserNames) {
echo $User
$User = [ADSI]("WinNT://$Domain/$UserName")
$Grp = [ADSI]("WinNT://$Domain/$NewGroupName")
$Grp.PSBase.Invoke("Add",$User.PSBase.Path)
}