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 (294k 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 (550 points)
0 votes
1 answer

Hi there, I've created a Delete User feature in the Web Interface Configurator. I am trying to restrict object selection via a User Criteria. Need to exclude Service ... won't appear when selecting target user for the 'Delete User' feature. Thanks, David

asked Sep 19 by dshortall (80 points)
0 votes
1 answer

I'm wanting to store information in a custom user attribute in Entra ID but I'm wondering if this is possible within a "Update the user" action in Adaxes? ... PowerShell? https://learn.microsoft.com/en-us/entra/external-id/customers/concept-user-attributes

asked Dec 11 by smcfarland (60 points)
3,588 questions
3,277 answers
8,303 comments
548,078 users