title: How can I test that a variable is more than eight characters in PowerShell?
body: <p>How do test if the number of characters in $dbUserName is more than eight characters?</p>
  
  <p>I have been unable to locate a command or series of commands that will let me do this. I have only been able to find if the variable is null:</p>
  
  <pre><code>if ($dbUserName) {
      Write-Output " You left Username blank"
      $dbUserName = read-host
  }
  </code></pre>
  
  <p>But I would like to next test like this:</p>
  
  <pre><code>if ($dbUserName [String] &gt; 8 ) }
      Write-Output " Please enter more than 8 characters "
      $dbUserName=read-host " Re-enter database user name"
  }
  </code></pre>