0 votes

Thanks for the info.

I'm now grabbing the %adm-ManagerUserName% value, but need to remove the final 21 characters of it so it contains only their username and not our domain. Following the guidance of the Set-AdmUser cmdlet, I created the script below:

$user = $Context.TargetObject

$MgrUserName = "%adm-ManagerUserName%" $MgrUserName = $MgrUserName.SubString(0,$MgrUserName.length-21)

Set-AdmUser "$user" -Add @{"adm-CustomAttributeText39"="$MgrUserName"} -AdaxesService localhost

However when testing this in the PowerShell Script Editor for my business rule, I get the following error:

image.png

by (60 points)

1 Answer

0 votes
by (270k points)

Hello,

The error occurs because the identity passed to the cmdlet is incorrect. It should be done using the Put method.

Also, values represented by variables should not be wrapped by quotes. The correct way to trim strings in such cases is using the identifier of the corresponding character. In this case, the separating character is @. Finally, your script should look exactly as follows:

$MgrUserName = "%adm-ManagerUserName%"
$MgrUserName = $MgrUserName.SubString(0, $MgrUserName.IndexOf("@"))

$Context.TargetObject.Put("adm-CustomAttributeText39", $MgrUserName)
$Context.TargetObject.SetInfo()
0

Thank you, that worked perfectly! I appreciate your guidance to a PowerShell newbie.

Related questions

0 votes
0 answers

When the UPN being created is the same as an existing one except for the case. For instance, the new UPN is sally.fields but there's an existing Sally.Fields. The ... but then fails to create the AD account indicating that the UPN is not unique forestwide.

asked Jul 13, 2022 by sandramnc (870 points)
0 votes
1 answer

Or is there another solution to solve this?

asked Sep 15, 2022 by boris (450 points)
0 votes
1 answer

Example: If a user has a ' in theirname: Fred J O'neal. Normally the username is set as %lastname:lower,4%%firstname:lower,3%%initials:lower% Problem is o'nefrej would be the result. ... name", "Information") $username = #this is what I'm not sure how to do?

asked Dec 6, 2022 by mightycabal (1.0k points)
0 votes
1 answer

This script description says it can find the manager via FullName Distinguished name or Display name. Wondering if we can change it to use employeeID or SamAccountName.

asked Oct 24, 2022 by mightycabal (1.0k points)
3,326 questions
3,026 answers
7,727 comments
544,684 users