title: If/Else in powershell to determine StrongAuthenticationStatus - powershell
body: <p>So I am trying to come up with a reliable method to determine if a user has o365 multi factor authentication configured on their account prior to a script running so They do not get re-enabled.</p>
  
  <p>using:</p>
  
  <pre><code>$MFAUsers = Get-Msoluser -userprincipalname test.webjea@xxx.com  | select "StrongAuthenticationRequirements"
  </code></pre>
  
  <p>outputs if they are enabled </p>
  
  <pre><code>StrongAuthenticationRequirements
  --------------------------------
  {Microsoft.Online.Administration.StrongAuthenticationRequirement}
  </code></pre>
  
  <p>and the following if they are disabled</p>
  
  <pre><code>StrongAuthenticationRequirements
  --------------------------------
  {}
  </code></pre>
  
  <p>Ideally if the user is disabled then the script will run against their account enabling it.  If they are enabled then the script will skip them.
  For testing I have this drawn up </p>
  
  <pre><code>if ($MFAUsers -eq "{Microsoft.Online.Administration.StrongAuthenticationRequirement}") {
  "NO MFA"
  } 
  Elseif ($MFAUsers -eq "{Microsoft.Online.Administration.StrongAuthenticationRequirement}"){
  "MFA"
  }
  </code></pre>
  
  <p>When running this against the test account that has been enabled I still get the "no MFA" response</p>
  
  <p>Anyone have any idea?  I'm sure it is something stupid but I really cant put my finger on it?  Is it seeing the "StrongAuthenticationRequirments" header?</p>