title: Get-AzResourceGroup : 'this.Client.SubscriptionId' cannot be null
body: <p>Having a bit of an issue with Azure and Powershell. I'm just checking to see if a resource group exists and I keep hitting this error. The next step after this is to create the resource group if it does not exist, but that is also throwing the same error. Was hoping someone might be able to suggest some workarounds or fixes.</p>
  
  <p>Please note, I have access to the subscriptions, I can see them and sucessfully set the default subscription as can be seen in the script below.</p>
  
  <p><strong>Full Error Returned</strong></p>
  
  <pre><code>'this.Client.SubscriptionId' cannot be null.
  At **********************\envir\create-env.ps1:21 char:1
  + Get-AzResourceGroup -Name $resourceGroup -ErrorVariable $doesNotExist ...
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : CloseError: (:) [Get-AzResourceGroup], ValidationException
      + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.GetAzureResourceGroupCmdlet
  </code></pre>
  
  <p>I've just installed the Az module, version details below.</p>
  
  <pre><code>Version    Name                                Repository
  -------    ----                                ----------
  1.6.0      Az                                  PSGallery
  </code></pre>
  
  <p>I'm just running a pretty straight forward script (below), I thought it might be something to do with a default subscription not been set, but setting that has made no difference.</p>
  
  <pre><code>$passwd = ConvertTo-SecureString $servicePrincipalKey -AsPlainText -Force
  $pscredential = New-Object 
  System.Management.Automation.PSCredential($servicePrincipalUserName, $passwd)
  Connect-AzAccount -ServicePrincipal -Credential $pscredential -TenantId $tenantId
  Select-AzureSubscription -Default -SubscriptionName $subscriptioName
  Get-AzResourceGroup -Name $resourceGroup -ErrorVariable $doesNotExist 
  </code></pre>
  
  <p>I then get the error listed above.</p>