title: Getting access token from Azure using MSAL.PS
body: <p>I have a Powershell script which should be run automatically (daemon) which needs authenticate to Azure AD.
  I have a "working" script to  which is getting the correct access token, but this requires me to manually enter username/password. How can I execute the script by having the username/password configured</p>
  
  <p>What has been done:</p>
  
  <ul>
  <li>A user is created in Azure and Office license has been assigned (this
  is the user which I have to enter username/password for)</li>
  <li>An app registration has been done ($clientid and $clientsecret in
  code below)</li>
  <li>Using MSAL.PS v4.10.0.2</li>
  </ul>
  
  <pre><code>$redirecturi = "&lt;redirect url&gt;"
  $redirecturi
  $scope = '&lt;scope&gt;'
  
  $sec = ConvertTo-SecureString $clientsecret -AsPlainText -Force
  $app = New-MsalClientApplication -ClientId $clientid -ClientSecret $sec -RedirectUri $redirecturi -TenantId $tenantid
  $az_access_token = $app | get-msaltoken -Scope $scope -LoginHint $loginhint | select -expand accesstoken
  
  </code></pre>