skip to Main Content

I am trying to execute Get-AzSqlServer from AzureCli@2 yaml pipeline and it is throwing an error:
The term ‘Get-AzSqlServer ‘ is not recognized as the name of a cmdlet

Here is my task

- task: AzureCli@2
  inputs:
   azureSubscription: 'serviceconnection'
   scriptType: 'ps'
   scriptLocation: 'inlineScript'
   inlineScript: |
    $sqlServer = Get-AzSqlServer -ResourceGroupName rgTest

2

Answers


  1. Try to use:

       pwsh: |    
         $sqlServer = Get-AzSqlServer -ResourceGroupName rgTest
    
    Login or Signup to reply.
  2. Use AzurePowerShell@5 if you want to run PowerShell in an authenticated session.

    You could also try running Import-Module for the appropriate Azure PowerShell modules, but I don’t guarantee that would work.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search