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 (233k 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

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 (90 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

Hello, I'm trying to setup a business rule that will send an email to the user when they are added to a group. Under the User Object I don't have an option to Launch ... to get the new group member's email address so I can send a notification to it? Thanks!

asked Dec 1, 2015 by drew.tittle (810 points)
0 votes
1 answer

I get this question quite a bit.... Our staff is used to being able to paste a well-formed listing of users into "Active Directory Users and Computers" when they are ... the web interface)? If not, are you considering adding this ability in the future? Thanks!

asked May 22, 2012 by BradG (950 points)
2,884 questions
2,604 answers
6,762 comments
119,176 users