title: How should I check if a computer account is already in an AD
body: <p>I've written a script to join a computer to a domain. The script runs in 2 parts, where the first is to prompt for a computer name, rename it, then set up a script to run the next boot to join to the domain. The next uses a WMIC command to join the computer to the domain silently through an automated task.</p>
  
  <p>Currently, we're having issues where if the end user types in a name that already exists in the AD,  the domain join script (running on next boot) fails without any user interaction or prompting to enter a new computer name.</p>
  
  <p>I was wondering if there was a way to test the computer name doesn't exist in the AD before trying to join the domain through batch scripting. I only need a subroutine to run as I have the rest of the logic sorted out (I.E. Re-Prompt or trim and add a sequential number to the end to resolve conflicts). </p>
  
  <p>The computers running this script are obviously not joined to the domain and are in a workgroup. I really appreciate any help!!</p>