<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D54z00009gRi1mCACOkta Identity EngineWorkflowsAnswered2023-09-28T21:27:56.000Z2023-09-21T23:49:02.000Z2023-09-28T21:27:56.000Z

ThomasL.38230 (Customer) asked a question.

"Execute On-Premise PowerShell with Okta Workflows" documentation not working

The updated Okta Workflows documentation on how to "Execute On-Premise PowerShell with Okta Workflows" appears to assume that replacing the steps to set up the old agent-based Hybrid Runbook worker with the new extension-based workers while keeping everything else the same should work. However, there are two issues, especially with the sample script given.

 

  1. The lack of a service principal results in the inability to get the refresh token to retrieve a runbook job's output.
  2. The new extension-based workers do not have the ability to 'runas' a local/domain administrator, resulting in cmdlets requiring elevation like like New-ADUser and Set-ADUser hitting "Access is denied/Insufficient access rights to perform the operation"

 

The lack of a service principal can be resolved by adding the App Registration to the Automation Account's IAM, and the Resource Group to the Identity.

 

However, I am still unable to figure out a solution to elevate the runbook script.

Has anyone here been able to get on-premise Powershell with elevation working since moving to an extension-based worker?

 

I have tried adding the following to my script but it made no difference:

if(-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }

 

I was using Okta Workflows to trigger creating new ADUsers when such a Jira service ticket came in, but it has since broken.

 

The guides I am referencing are below:

https://{{domain}}.workflows.okta.com/app/templates/execute_onpremise_powershell_with_okta_workflows

https://github.com/okta/workflows-templates/blob/master/workflows/execute_onpremise_powershell_with_okta_workflows/readme.md


BrockC.45838 likes this.
  • TimL.58332 (Workflows)

    @ThomasL.38230 (Customer)​  -- I have reached out to the owner of this process. I cannot make any guarantees but will update this thread once I hear back.

  • TimL.58332 (Workflows)

    @ThomasL.38230 (Customer)​ - I discussed this with the process owner and they are requesting the following:

     

    • Re-Step through the instructions and ensure no steps were missed.
    • If no steps were missed: open a formal support case in Workflows.

     

    Assuming you are available in my time frame I will like take ownership of the case to coordinate. If everything is setup correctly per the provided instructions and it is not functioning we will likely need to investigate with the process owner.

     

     

    Expand Post
  • ThomasL.38230 (Customer)

    @TimL.58332 (Workflows)​ 

     

    I can confirm I've followed the instructions to ensure no steps were missed.

    Any script not requiring elevation works (eg. Get-ADUser).

     

    Scripts where elevation is required (eg. New-ADUser/Set-ADUser) have insufficient access/permissions.

     

    I've tore down and recreated the automation account, resource group, and hybrid workers following the instructions in the link and have not had success.

     

    Microsoft Azure support helped me figure out the inability to get the job status and output of a runbook job, but have so far been unable to help me figure out how to elevate the script.

     

    I will a formal support case in Workflows, but this appears to be more of an Azure issue than Okta's.

     

    Thomas

    Expand Post
  • ThomasL.38230 (Customer)

    @TimL.58332 (Workflows)​ 

     

    After reaching out to multiple support avenues, others have confirmed that the documentation as written does not work, although we were able to find a resolution.

     

    1. The lack of a service principal results in the inability to get the refresh token to retrieve a runbook job's output, resulting in {"code":"AuthenticationFailed","message":"Authentication failed. The 'Authorization' header is missing."}}. This can be resolved by doing the following:
      1. Under Azure\Automation Accounts\Account Settings\Identity, add the Azure role assignment of Contributor.
      2. Under Azure\Automation Accounts\Access Control (IAM), add the App Registration as a as a Reader
      3. After performing these steps, the workflow's [1.1] Get Azure Automation Job Status will be able to get the job's status and output.
    2. The new extension-based hybrid workers run under the local SYSTEM account of the worker, but lacks the rights to make changes in the AD, resulting in the error Access is denied. In order to create or modify AD objects, or perform any other task requiring different permissions, the following needs to be done:
      1. Under Azure\Automation Accounts\Shared Resources\Credentials, add the credential of a user or service account on the AD with permissions to create/edit AD objects, and note the name (eg. MyCredentials)
      2. In the Powershell script, add the following line of code near the beginning of the script (but after the Params): $Cred = Get-AutomationPSCredential -Name "MyCredential"
      3. For any AD cmdlets that require additional privileges (eg. Set-ADUser; New-ADUser), add the following code at the end: -Credential $Cred
      4. In the case of the example in the documentation, it would now be: Set-ADUser -Identity $memberSamAccountName -Replace @{logonhours = $hours1} -Credential $Cred

     

    I hope this helps. If necessary, please forward this to @bryan.barrows1.5613819579051719E12 (Okta, Inc.)​ to update the documentation.

     

    Thomas

    Expand Post
This question is closed.
Loading
"Execute On-Premise PowerShell with Okta Workflows" documentation not working