title: Azure: How to check storage account exists in Azure with Get-AzureStorageAccount
body: <p>I am building a power shell script to automate the setup of a website environment in Azure. This web uses an account storage. I want to the script not to create the account storage if exists.</p>
  
  <p>I thought that using <code>Get-AzureStorageAccount</code> this way may work but it does not:</p>
  
  <pre><code>Write-Verbose "[Start] creating $Name storage account $Location location"
  
  $storageAcct = Get-AzureStorageAccount –StorageAccountName $Name
  if (!$storageAcct)
  {   
      $storageAcct = New-AzureStorageAccount -StorageAccountName $Name -Location $Location -Verbose
      if ($storageAcct)
      {
          Write-Verbose "[Finish] creating $Name storage account in $Location location"
      }
      else
      {
          throw "Failed to create a Windows Azure storage account. Failure in New-AzureStorage.ps1"
      }
  }
  else
  {
      Write-Verbose "$Name storage account in $Location location already exists, skipping creation"
  }
  </code></pre>
  
  <p>The issue is I don't know how to handle the return of <code>Get-AzureStorageAccount</code>.</p>
  
  <p>Thank you very much in advance!</p>