Running powershell code from azure devops pipeline - Stack Overflow

admin2025-04-16  0

I am deploying powerapps using azure devops pipeline. At the end I have added a powershell task and added the code

Set-AdminPowerAppApisToBypassConsent -EnvironmentName 00aa00aa-bb11-cc22-dd33-44ee44ee44ee -AppName 00001111-aaaa-2222-bbbb-3333cccc4444

When I run the pipeline the powershell task keeps on running for too long without any output. When I run the same code in my windows powershell, it opens a popup to authenticate.

How can we achieve the same in pipeline?

I am deploying powerapps using azure devops pipeline. At the end I have added a powershell task and added the code

Set-AdminPowerAppApisToBypassConsent -EnvironmentName 00aa00aa-bb11-cc22-dd33-44ee44ee44ee -AppName 00001111-aaaa-2222-bbbb-3333cccc4444

When I run the pipeline the powershell task keeps on running for too long without any output. When I run the same code in my windows powershell, it opens a popup to authenticate.

How can we achieve the same in pipeline?

Share edited Mar 11 at 21:47 James Z 12.3k10 gold badges27 silver badges47 bronze badges asked Mar 11 at 7:21 KumarVKumarV 1622 silver badges14 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Since this PowerShell cmdlet needs you manually enter the authenticate information on a popup, you need to configure a self-hosted agent to run interactively on your Windows machine.

  1. Download the latest installation package of the Windows agent. It will download a ZIP file.

  2. Unzip the ZIP file to the installation directory of the agent where you want.

  3. Open PowerShell as Administrator in the installation directory of the agent and run .\config.cmd to start configure the agent steps by step following the series of questions:

    • Enter the URL of Azure DevOps anization (https://dev.azure/{anization-name}), or Azure DevOps Server collection (https://{server-instance}/{collection0name}).
    • Enter the Personal Access Token (PAT) from Azure DevOps for connecting to the Azure DevOps anization/collection. This PAT should have "Agent Pools (Read & manage)" scope at least.
    • Enter the name of the pool where the agent will be added in, and a custom name of the agent.
    • Enter run agent as service? (Y/N): Directly press Enter key to set the agent to run interactively.
    • Enter configure autologon and run agent on startup? (Y/N): Enter Y to enable auto-logon and run the agent every time when the Windows machine is startup.
    • Enter the username and password for auto-logon. Ensure the provided username and password are correct and valid to logon the Windows machine.
    • Enter Restart the machine at a later time? (Y/N): If enter Y, the Windows machine will not Restart immediately, and you can manually Restart it later. If N, the machine will Restart immediately. Before using this agent, you should Restart machine at least once.

After completing the configuration of the agent, and Restart the Windows machine, you can a command prompt is automatically opened and listening if there is any jobs in queue are waiting to use this agent. It is running the self-hosted agent by auto-logon.

Keep the command prompt open, go to Azure DevOps and set your pipeline to run this self-hosted agent, and then run the pipeline. When the PowerShell task is running, you also can see a popup is opened on the self-hosted Windows agent machine to ask you to manually provide the authenticate information.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1744809608a268204.html

最新回复(0)