Share via

##[error]PowerShell exited with code '1'.

Brilliant Mohapi 0 Reputation points
2026-06-11T07:37:31.25+00:00

I keep getting the bellow error no matter how I change the yml file. Please advice.

  1. Starting: Configure Android ============================================================================== Task : PowerShell Description : Run a PowerShell script on Linux, macOS, or Windows Version : 2.226.1 Author : Microsoft Corporation Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell ============================================================================== Generating script. ========================== Starting Command Output =========================== "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\automationagent_work_temp\9082324d-62bb-4d67-a0dd-687373a57082.ps1'" ANDROID_HOME = C:\Android\Sdk C:\automationagent_work_temp\9082324d-62bb-4d67-a0dd-687373a57082.ps1 : adb not found At line:1 char:1
    • . 'C:\automationagent_work_temp\9082324d-62bb-4d67-a0dd-687373a5708 ...
    •    
             + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException 
         
             + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,9082324d-62bb-4d67-a0dd-687373a57082.p  
         
            s1 
         
      
    ##[error]PowerShell exited with code '1'. Finishing: Configure Android
Azure DevOps
0 comments No comments

2 answers

Sort by: Most helpful
  1. Rakesh Mishra 9,680 Reputation points Microsoft External Staff Moderator
    2026-06-11T14:40:51.21+00:00

    Hello Brilliant Mohapi,

    Thank you for reaching out on the Microsoft Q&A portal!

    The error message adb not found resulting in ##[error]PowerShell exited with code '1' occurs because your PowerShell script is trying to execute an Android Debug Bridge (adb) command, but the directory containing adb.exe is not registered in the system's PATH environment variable. Even though your logs confirm that ANDROID_HOME = C:\Android\Sdk is set, the actual adb executable resides in a specific subdirectory called platform-tools which needs to be explicitly targeted.

    Here are a few ways to resolve this issue depending on your agent type:

    Option 1: Switch to a Microsoft-hosted Agent (Recommended): If you are running a self-hosted agent or a custom image, the easiest way to avoid manual tool configuration is to switch your pipeline pool to use a Microsoft-hosted agent. According to the Azure Pipelines agents documentation:

    "With Microsoft-hosted agents, maintenance and upgrades happen automatically. You always have the latest version of the VM image you specify in your pipeline."

    The windows-latest or ubuntu-latest images already have the Android SDK and platform-tools (including adb) pre-installed and correctly mapped to the PATH.

    pool:
      vmImage: 'windows-latest'
    

    Option 2: Update the PATH directly in your PowerShell Task: If you are bound to a self-hosted agent where the SDK is present at C:\Android\Sdk, you can temporarily append the platform-tools directory to the PATH inside your YAML script right before you invoke the adb commands.

    - task: PowerShell@2
      displayName: 'Configure Android'
      inputs:
        targetType: 'inline'
        script: |
          # Append platform-tools to the current session's PATH
          $env:Path += ";C:\Android\Sdk\platform-tools"
          
          # adb will now be recognized
          adb version
          
          # Call your actual script here:
          . 'C:\automationagent_work_temp\your_script.ps1'
    

    Option 3: Permanently update the System PATH (Self-hosted Agent): If you are managing your own self-hosted build agent, you can update the system variables so that every pipeline run natively recognizes adb:

    1. Log into your agent VM.
    2. Download the Android Command Line tools if you haven't already.
    3. Open Windows search, type Environment Variables, and select Edit the system environment variables.
    4. Under System variables, locate the Path variable and click Edit.
    5. Add the entry: C:\Android\Sdk\platform-tools
    6. Important: Restart the Azure Pipelines Agent service on the machine so that the runner session picks up the new environment variables.

    Hope this helps! Let us know in comments if you need any further assistance.

    Note: This response is drafted with the help of AI systems.

    Was this answer helpful?

    0 comments No comments

  2. AI answer

    2026-06-11T07:37:49.19+00:00

    The log shows that the PowerShell task fails because adb is not found, and the script writes an error, which causes PowerShell to exit with code 1.

    To resolve this in the pipeline:

    1. Ensure the Android SDK (including platform-tools) is installed on the build agent and that the adb executable exists under something like C:\Android\Sdk\platform-tools\adb.exe.
    2. Update the PATH in the PowerShell task (or a preceding step) so that the directory containing adb is included. For example, in a PowerShell@2 task:
         - task: PowerShell@2
           inputs:
             targetType: 'inline'
             script: |
               $env:PATH = "C:\Android\Sdk\platform-tools;" + $env:PATH
               adb version
      
      This ensures adb can be resolved when the script runs.
    3. If the script itself writes an error (for example using Write-Error or Write-Host "##vso[task.LogIssue type=error;]..." followed by exit 1), remove or adjust that logic so it only writes an error and exits with 1 when there is a real failure.
    4. If adb is not required for this step, remove or conditionally skip the adb calls from the script.

    Once adb is on PATH (or the script no longer calls it), the PowerShell task will stop failing with PowerShell exited with code '1'.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.