title: How can I check password complexity?
body: <p>I am using PowerShell to create local users. I need to get input from keyboard: Username &amp; Password. To get the password I can use one of the following:</p>
  
  <pre><code>$user_details = Get-Credential
  </code></pre>
  
  <p>or</p>
  
  <pre><code>$pass = Read-Host -assecureString "Please enter your password"
  </code></pre>
  
  <p>In both cases, I will get encrypted password variable <code>System.Security.SecureString</code>. In both cases, when I try to create the user, with</p>
  
  <pre><code>New-LocalUser -Name $username -Password $pass
  </code></pre>
  
  <p>I get an error that the password is not complex.</p>
  
  <blockquote>
    <p>New-LocalUser : Unable to update the password. The value provided for
    the new password does not meet the length, complexity, or history
    requirements of the domain."</p>
  </blockquote>
  
  <p>Since the password is encrypted, (System.Security.SecureString) I have no way to know the complexity of the password. How can I force the user to type a password that complies the complexity rules?</p>
  
  <p>(using unencrypted passwords is not a good solution for me)</p>
  
  <p>Update:
  After few answers that were relevant with good solutions, but did not meet my security requirement, I'd like to rephrase:</p>
  
  <p>How can I check password complexity which is already stored in object:
  System.Security.SecureString (without decryption)</p>