0 votes

Hello, I have a scheduled task that update the employeeID from a value in our ERP system. Right now the task runs a Powershell script that gathers the info and then uses Set-AdmUser to set the attribute. A business rule then kicks in to send the operation for approval. This allows us to monitor what is going on, and to view what the EmployeeID is being set to (as a sanity check) before we allow the change. Eventually we'll probably just let it run wild with no checks, but that's in the far future.

Everything works fine, but the logs for the scheduled tasks always show that an error occurred, the message attached to the error just states that "This operation requires approval." This will make it difficult to distinguish actual errors from the task running as it should.

Is there a way to stop the logs from showing an error when approval is required? Or is there a better way to handle the whole process?

Thanks in advance.

by (350 points)
0

Hello,

Can you post here or send to our support e-mail (support@adaxes.com) the text of the PowerShell script that you use in the Scheduled Task for importing data from the ERP system?

1 Answer

0 votes
by (216k points)
selected by
Best answer

Hello,

In your script, you update users with the help of the Set-AdmUser cmdlet, which throws an exception with the 0x8000000A error code when an operation is set for approval. To avoid such an issue, you need to use the try...catch block. For this purpose:

  1. In your script, find the following line:

     Set-AdmUser -Identity %username% -EmployeeID $AS400EmployeeID -AdaxesService localhost
  2. Replace it with the following block:

     try
     {
         Set-AdmUser -Identity %username% -EmployeeID $AS400EmployeeID -AdaxesService localhost -ErrorAction Stop
     }
     catch
     {
         if ($_.Exception.ErrorCode -ne 0x8000000A)
         {
             Write-Error $_.Exception.Message
         }
     }
0

This seems to have done the trick. Thanks for the insight!

Related questions

0 votes
1 answer

On Approval Requests, in the web console, Initiator shows "N/A" instead of the custom command scheduled task. The admin console shows the custom command scheduled task though. Any way to fix that?

asked Jan 21, 2021 by mark.it.admin (2.3k points)
0 votes
1 answer

Hello, I am trying to figure out how to create a scheduled task via PowerShell. I've been referencing the SDK, mostly pulling script examples straight out of it. After following the steps on ... ==================> # Save the Scheduled Task $task.SetInfo()

asked Feb 23, 2015 by DFassett (710 points)
0 votes
1 answer

Using the powershell module, I know how to create a scheduled task, and also how to bind to a scheduled task that is already known. I also have used code to try creating ... same time as another. These are all one-time tasks and will be removed once executed.

asked Jan 19 by aweight (40 points)
0 votes
1 answer

So I have custom forms for onboarding / offboarding users. We sometimes know 2-3 weeks in advance so I would like to add the ability to schedule these for the future. I ... to take all the data that was inputed and then process the request on the given date?

asked Aug 4, 2023 by thatcher (120 points)
0 votes
1 answer

Hello! how do i manage do get adaxes to remove all groups from the user after one month? We have a Business Rule where you can add an end of Date when the Account ... value field the powershell script works but not with the +1 Month. Thanks for your help!

asked Jun 14, 2023 by eww ag (140 points)
3,346 questions
3,047 answers
7,772 comments
544,973 users