I have a scheduled task that runs a Powershell script against an AD group, "Group 1". I need to get all of the members of Group 1, and add them to Group 2. The script below successfully removes the user from Group 1 but I get an error at the Add-AdmGroup member line:
Can't find an object with identity 'user;Adaxes://domain.com/CN=User Name,OU=Users,DC=domain,DC=com'.
$group = $Context.TargetObject
$members = $group.Members()
$members | ForEach-Object {
$group.Remove($_.ADsPath)
$Context.LogMessage("Removed group member " + $_.Name, "Information")
Add-AdmGroupMember "Group 2" $_
}
Why does the identity in the error message start with 'user;'? What is the correct way to accomplish this?