title: How to authorize clients in non-default directory to KeyVault
body: <p>I created a KeyVault in my Azure subscription and a client application in one of my Azure AD directories. However, the client application is not registered in the <strong>default directory</strong> of the subscription.</p>
  
  <p>When I run the following PowerShell cmdlet, it tries to look up the service principal in the default directory of the subscription and fails to find it.</p>
  
  <pre><code>PS &gt; Set-AzureKeyVaultAccessPolicy -VaultName &lt;vaultname&gt; 
         -ServicePrincipalName &lt;principal guid&gt; -PermissionsToSecrets Get
  </code></pre>
  
  <p>I found <a href="http://rickrainey.com/windows-azure-how-tos/how-to-change-the-directory-associated-with-your-windows-azure-subscription/" rel="nofollow">an article</a> describing how to change the default directory for a subscription in the management portal, but was wondering how to do the same using PowerShell. </p>
  
  <p>The '<a href="https://msdn.microsoft.com/en-us/library/dn495203.aspx" rel="nofollow"><code>Select-AzureSubscription</code></a>' cmdlet does not seem to support changing the default directory.
  Nor does the '<a href="https://msdn.microsoft.com/en-us/library/dn903607.aspx" rel="nofollow"><code>Set-AzureKeyVaultAccessPolicy</code></a>' support a parameter to indicate in which directory it should look.</p>