0 votes

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 {    
    $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?

by (220 points)

1 Answer

0 votes
by (272k points)
selected by
Best answer


Why does the identity in the error message start with 'user;'?

This happens because the object being removed from one group and added to another is a user account. The error itself occurs because the Members method returns objects that cannot be used in the Members parameter of the Add-AdmGroupMember cmdlet. For details, see https://www.adaxes.com/sdk/?Add-AdmGrou ... er_Members.

What is the correct way to accomplish this?

Have a look at the following script from our repository: https://www.adaxes.com/script-repositor ... s-s548.htm.


Thanks, that did it.

Related questions

0 votes
1 answer

Hello, I am attempting to configure a business rule that adjusts an adaxes custom property of a user, upon that user being added/removed from a group. I cannot seem to ... (like username, office, description, email, etc.) but not so much on custom attributes.

asked Jul 14, 2023 by NKB#2772 (70 points)
0 votes
1 answer

Hello! how do i manage do get adaxes to remove all groups from the user after one month? We have a Business Rule where you can add an end of Date when the Account ... value field the powershell script works but not with the +1 Month. Thanks for your help!

asked Jun 14, 2023 by eww ag (140 points)
0 votes
1 answer

Hello Back when we first started using Adaxes you created a couple of great scripts which worked together really well, the first one copied one users group membership and put in ... an addition to what groups the second user is already a member of? Thank you.

asked Aug 4, 2015 by CBurn (700 points)
0 votes
1 answer

Currently, when I disable a user account in Adaxes, the group memberships of the user remain intact. I'd like to automate the removal of group memberships such as distribution ... a list of groups/DL that the user was previously in and removed from. Thanks!

asked Nov 3, 2021 by jayden.ang (20 points)
0 votes
1 answer

We have a potentially complicated sitaution and so far I have no found a solution. Any suggestions will be greatly appreciated. We have specific security groups that ... or see any user details other than the memberships for these specific security groups.

asked Jan 2, 2023 by WannabeGuru (20 points)
3,343 questions
3,044 answers
544,953 users