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 (289k 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
0 answers

Hi All, I have setup an action to cancel all meetings in outlook when a user is leaving. We use Exchange online but I'm getting an error 'The operation is supported by Exchange online and Exchange versions starting from 2019' I cant see where you specify.

asked Sep 6 by DarrenFisk (60 points)
0 votes
1 answer

Is there any way to add a warning message when someone tries to add a group member that already is member? Checked config but found nothing related. Added a new member that ... the group and there is no warning, and the logs show that the task was completed.

asked Jul 9 by lramirez (20 points)
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 (290 points)
3,548 questions
3,238 answers
8,232 comments
547,811 users