title: Automate Authentication to Azure as Service Principal using Windows Powershell
body: <p>I need to use Powershell for some automated Jenkins jobs. To do the work, I need to authenticate as a Service Principal in a non-interactive fashion.</p>
  
  <p>With the Azure CLI, this can be accomplished non-interactively using the following command:</p>
  
  <pre><code>az login --service-principal -u "$client_id" -p "$client_secret" -t "$tenant_id"
  </code></pre>
  
  <p>However, accomplishing this using the <code>Connect-AzAccount</code> cmdlet for Powershell is proving to be tough. Is there anyway to achieve the same result as above using a Powershell cmdlet? All of the options <a href="https://docs.microsoft.com/en-us/powershell/module/az.accounts/connect-azaccount?view=azps-1.6.0#examples" rel="nofollow noreferrer">described here</a> seem to be interactive only.</p>
  
  <p>Any help would be greatly appreciated.</p>