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)
by (216k 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

by (216k points)
Best answer
0 votes

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
         }
     }
by (350 points)
0

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

Related questions

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

Hello, We have a task which checks every hour if jobs have been added to a list (CSV-File) and if so will start provisioning tasks including Microsoft Teams. If ... job has completed or is still running to prevent duplicate runs. Is this somehow possible?

asked Sep 25 by andrep (20 points)
0 votes
1 answer

Let's say that I have a scheduled task that adds a high-level roles-based AD group to a user. As part of that same task, I'd like to run a powershell script to collect all ... the task to type in the "parent" group name, and pass it to the script that way?

asked Sep 22 by 3Jake (190 points)
0 votes
1 answer

We have a security initiative to disable the default Exchnage Online (EXO) PowerShell access for users, while retaining access for Admins. I would like to implement ... com/en-us/powershell/exchange/disable-access-to-exchange-online-powershell?view=exchange-ps

asked Mar 14 by Mark.Monaco (40 points)
0 votes
1 answer