skip to Main Content

Do you have any idea why it’s not working correctly?

$resut = az sql db show --name "NotExistingDB" --resource-group "rg" --server "server" | ConvertFrom-Json

checking if database exists – it should return false because it does not.

$? :- Writing result of last command, it returns $true in my case but should return $false.

2

Answers


  1. https://github.com/Azure/azure-cli/pull/24015

    #23514 added az.ps1 so that when Azure CLI is invoked in PowerShell, az.ps1 is called instead of az.cmd.

    This change caused a number of issues and is being reverted. Though your specific issue is not listed, I can also reproduce it and it fits with the change. A fix will be released soon as far as I can see.

    You can also try going back to an old version of Azure CLI to see if that fixes the issue.

    Login or Signup to reply.
  2. I have reproduced in my environment by using your command, and I got the expected results as below:

    enter image description here

    I got true when the resource is found else, I got false as discussed in comments too.

    I used the newer version of powershell and cli , please try to use it:

    enter image description here

    enter image description here

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