0 votes

Hello.

We need Adaxes to run a script every night that strips leading zeroes off of employee ID. Or better yet (each time the employee ID is set or changed?)

Example: Tech puts in 000556 as the employee ID when making a new user OR modifying an existing users employee ID. It will strip it down to 556

Would powershell be the way to do this?

Thanks

by (60 points)

1 Answer

0 votes
by (289k points)

Hello,

Yes, it should be done using a PowerShell script. To handle the cases when the property is updated in Adaxes, you need to use a business rule triggering After updating a user. However, if the changes are made outside of Adaxes, the rule will not trigger. To make sure that such cases are also handled and all current property values are trimmed accordingly, use a scheduled task. Both the business rule and the scheduled task will use the below script. In the script:

  • $propertyName - Specifies the LDAP name of the property to update.
  • $characterToTrim - Specifies the character that should be trimmed from the beginning of the property value.
  • $pipelined - Specifies whether the update will be passed through Adaxes pipeline. If set to True, corresponding business rules will trigger, log records will be created, etc.
$propertyName = "employeeID" # TODO: modify me
$characterToTrim = "0" # TODO: modify me
$pipelined = $True  # TODO: modify me

# Get current property value
$targetObject = $Context.BindToObjectByDNEx("%distinguishedName%", $pipelined)
$currentValue = $targetObject.Get($propertyName)

# Update property
$newValue = $currentValue.TrimStart($characterToTrim)
$targetObject.Put($propertyName,$newValue)
$targetObject.SetInfo()

Finally, you should have something like the following:

Business rule image.png Scheduled task image.png

0

I am trying to run this and am getting the following error. I am trying this from scheduled tasks.

Exception calling "Get" with "1" argument(s): "The 'employeeID' property cannot be found in the cache." Stack trace: at <ScriptBlock>, <No file>: line 7

You cannot call a method on a null-valued expression. Stack trace: at <ScriptBlock>, <No file>: line 10

It looks like it runs OK when I pick a specific user account under scheduled task. But if I try to make it run against an OU (lots of users) it gives this error.

0

Hello,

The error occurs because the property specified in the $propertyName variable of the script is empty. You need to make sure that conditions of the scheduled task are configured so that users with empty property value are not affected. For example, you can make it using the condition we provided in the screenshot.

0

Thanks. Adding the condition to scheduled tasks fixed the error.

0

Hello,

Thank you for the confirmation. The condition will also make sure that the scheduled task skips users that already have the property value not starting with zero.

Related questions

0 votes
0 answers

Hi Is it possible after creating a user, run a script in the background that generates the next Employee ID, assign it to the user then email it to interested parties? If not, ... ID with some kind of check, that makes sure it is not being used? Cheers D

asked Feb 15, 2016 by DFirmin (20 points)
0 votes
0 answers

All of full time employees have an employee ID, the issue I have is trying to display the employee ID field in a web portal page. I have both the employee ID and ... have a value displayed in the employee ID field. your assistance would be very helpful. Tony

asked Jul 15, 2015 by babbeaw (320 points)
0 votes
1 answer

I would like to know more about Employeed ID. It appeards you can add this info in Adaxes but of course nothing shows in ADUC. Is it truly in AD and only visible in Adaxes ... post/2009/06/21/Add ... splay.aspx Can adaxes enter both Employee # and Employee ID?

asked Aug 22, 2012 by It_helpdesk (280 points)
0 votes
1 answer

hello i'm new with Adaxes i'm try to creat schuadle task to import a spefice user list by thier username id after that just update City for them by bulk updating . kinly advise

asked Aug 29, 2023 by sudox (20 points)
0 votes
1 answer

We noticed when renaming a user or changing the UPN it does not update in office365. I can change the username field by usign the following command from azure ... seamless task for our helpdesk? Can adaxes do this natively without a powershell script?

asked Oct 25, 2018 by huuchuan1113 (50 points)
3,548 questions
3,239 answers
8,232 comments
547,814 users