0 votes

Hi

I need to execute the script when user is added to a group.
In that script I need to access group properties - name, etc. and user's properties.
I have no problem with group ones however can't figure out how to get the user that's being added to a group.

Tried to use:
$userObj = $Context.Initiator;
$user = $Context.BindToObject($userObj);
$firstname = $user.Get("firstname");

That doesn't work. Also I don't think Initiator is giving me the right user.

Any help will be much appreciated.
V.

by (100 points)

1 Answer

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

Hello,

You need to use the %member% value reference to bind to the user that was added to the group and get their properties. For example, to get the First Name of the user, use the following code:

$member = $Context.BindToObjectEx("Adaxes://%member%", $True)
$firstName = $member.Get(“givenName”)
0

Sorry one more question. Is it possible to get string (GUID) value for AD attribute "objectGUID"

$id = $member.Get(“objectGUID”) returns hex string

Thanks
V.

0

Hello,

Yes, it is possible. Use the following code:

$id = [Guid]$member.Get("objectGUID")
$stringID = $id.ToString()

Related questions

0 votes
1 answer

Good Morning, On our help desk's actions they have two options, "Add to Group" and "Modify User". When they attempt to add a user to a group with "Add to group", ... help desk security role full access to group objects, but still no luck. Any ideas? Thanks.

asked Feb 18, 2016 by jhair (520 points)
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

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 ... identity in the error message start with 'user;'? What is the correct way to accomplish this?

asked Aug 27, 2019 by ngb (220 points)
0 votes
1 answer

HI Support, I'm looking for a business Rule that remove a user from a couple of groups after the User is added to a group. ie 1. The User MaxMi is added to the ... not able to create a powershell scripts for removing the added user from the other Groups. Thx,

asked Jan 4, 2016 by Napoleon (700 points)
0 votes
1 answer

I need a way of triggering a business rule based on the user (and not the group) being added or removed from a group. The reason I would like this triggered on the user is so ... prefer not to do that. I am checking to see if there is another way to do this.

asked May 16, 2023 by mark.it.admin (2.3k points)
3,346 questions
3,047 answers
7,772 comments
544,970 users