title: How do I store a MFA credential in Powershell
body: <p>Under Basic authentication you used to be able to store credentials in a variable</p>
  
  <pre><code>$cred = Get-Credential
  </code></pre>
  
  <p>Now we are using Modern Auth and our Multi Factor Authentication is Duo.</p>
  
  <p>How do I store my credentials for MFA into a variable so I can plug them into a script?</p>
  
  <p>Example</p>
  
  <pre><code>$mfacred = *whateverthecodeis*
  Connect-MsolService -Credential $mfacred
  Connect-AzureAD -Credential $mfacred
  </code></pre>
  
  <p><strong>Edit</strong>
  I do not want to bypass MFA, I want to prompt for it and store the credentials and token in such a way that the rest of the script can make use of the credentials and token.</p>