title: How to check if an AD user exists
body: <p>I am working on error checking in my "Copy AD User" powershell script.  I use forms to ask for specific information, and the purpose of this question is to make sure i'm putting in error checking correctly.</p>
  
  <pre><code>IF ($Username.Text -eq Get-ADUser ($Username.Text))
      {$wshell = New-Object -ComObject Wscript.Shell
      $wshell.PopUp("This username already exists.  Please choose another")}
  </code></pre>
  
  <p>The <code>$Username.Text</code> is the text box where the username for the new account is being pulled from.  I want to run this through AD to see if that username already exists, and then display a message if it does.</p>
  
  <p>Am I going about it the correct way?</p>
  
  <p><a href="https://pastebin.com/cYdsWfZ8" rel="nofollow noreferrer">Pastebin of Full Code</a></p>