0

I've been attempting to use PowerShell PowerApps cmdlets (https://powerapps.microsoft.com/en-us/blog/gdpr-admin-powershell-cmdlets/ ) in DevOps and failing. They work very well on the desktop but when I run them in a PowerShell task in DevOps it just always stalls, no error. It simply runs but never finished or reports an error. I'm sure there's some detail I'm missing I just do not know what. Can anyone help get me on the right track?

5
  • So for example if you run this powershell, what do you see in the logs: Write-Host "##vso[task.logissue type=command]Testing powershell" Commented Aug 9, 2021 at 5:57
  • I would suggest following this learn.microsoft.com/en-us/power-platform/alm/devops-build-tools . After creation of a Service Principal you could create a ServiceConnection in AzureDevops and depend on AzurePowershell task. Else create secret variable and use it with PowerShell task Commented Aug 9, 2021 at 6:14
  • @Nick.McDermaid I get this back: 2021-08-09T06:31:24.2836583Z ##[error]Unable to process command '##vso[task.logissue type=command]Testing powershell' successfully. Please reference documentation (go.microsoft.com/fwlink/?LinkId=817296) 2021-08-09T06:31:24.2846958Z ##[error]issue type command is not an expected issue type. Am I missing a dependency here? Commented Aug 9, 2021 at 6:37
  • @koushik yes I do use a service principal and MS's build tools for most tasks but haven't tried the AzurePowerShell task. Commented Aug 9, 2021 at 6:37
  • 1
    @LarsChristianJensen to log issues from Powershell, Write-Host "##vso[task.logissue type=error]There is a error" Commented Aug 9, 2021 at 8:28

1 Answer 1

1

I suppose you used an interactive way to login with Add-PowerAppsAccount. In Azure DevOps pipeline, the interactive way is not supported.

In this case, your option is to install the modules with -Force and use a non-interactive way to login, e.g. as mentioned in the blog.

Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Force
Install-Module -Name Microsoft.PowerApps.PowerShell -AllowClobber -Force

$pass = ConvertTo-SecureString "password" -AsPlainText -Force
Add-PowerAppsAccount -Username [email protected] -Password $pass

Note: Make sure the user account is not MFA-enabled, otherwise you could not use it in the pipeline.

Sign up to request clarification or add additional context in comments.

1 Comment

Worth a mention, this is a good approach when working with the public PowerShell Gallery but if using an internally-hosted gallery feed I would recommend marking the repository as trusted, provided public packages are not available through it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.