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

If I have a scheduled task powershell script that's targeting an OU of users and in that script I were to call $context.cancel in the case of an error happening for a single ... it cancel the entire scheduled tasks and it won't run for other users in that OU?

asked Oct 18 by wrichardson (20 points)
0 votes
1 answer

Hello, I've created a custom command to run a script which will send an email alert if the script encounters an error. I have the command set to run as a scheduled task ... script that sends it: Custom Command Name: Task Name: Time: Error Message: Thank you.

asked Sep 17 by GronTron (320 points)
0 votes
1 answer

Similar to Powershell's "whatif"? I'd like to enable this scheduled task - But would like to confirm who will actually be affected before enabling this. Is there at least ... objects in the console log? I could run that before adding the 'modify' actions back.

asked Jun 25 by msinger (210 points)
3,549 questions
3,240 answers
8,232 comments
547,820 users