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?

  • So for example if you run this powershell, what do you see in the logs: `Write-Host "##vso[task.logissue type=command]Testing powershell"` – Nick.Mc Aug 09 '21 at 05:57
  • I would suggest following this https://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 – koushik Aug 09 '21 at 06: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 (http://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? – Lars Christian Jensen Aug 09 '21 at 06:37
  • @koushik yes I do use a service principal and MS's build tools for most tasks but haven't tried the AzurePowerShell task. – Lars Christian Jensen Aug 09 '21 at 06:37
  • 1
    @LarsChristianJensen to log issues from Powershell, Write-Host "##vso[task.logissue type=error]There is a error" – koushik Aug 09 '21 at 08:28

1 Answers1

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 foo@bar.com -Password $pass

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

Joy Wang
  • 39,905
  • 3
  • 30
  • 54
  • 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. – codewario Aug 18 '21 at 21:32