title: How to extract field content in powershell
body: <ul>
  <li><p>History: I'm making a Powershell script in order to create user from a defined table containing list of users and put them in a defined OrganizationalUnit.</p></li>
  <li><p>Problem: At the end of the script, I'd like to have a report in order to list whether or not there is one or many user account disabled amoung newly created account</p></li>
  </ul>
  
  <p>In my script, I have to input a password for each user, but I may enter a password that won't meet the password policy defined in Active Directory; in this case, the account will be created but disabled.</p>
  
  <p>To proceed, I tried :</p>
  
  <pre><code>dsquery user "ou=sp,dc=mydomain,dc=local" -disabled
  </code></pre>
  
  <p>and it print me this :</p>
  
  <pre>
  "CN=user1,OU=SP,DC=mydomain,DC=local"
  "CN=user2,OU=SP,DC=mydomain,DC=local"
  "CN=user3,OU=SP,DC=mydomain,DC=local"
  </pre>
  
  <ul>
  <li><p>My goal : I'd like to extract in a variable the values in "CN" field in order to compare them to the inital user table in my script.</p>
  
  <pre><code>dsquery user "dc=mydomain,dc=local" -disabled | where-object {$_.CN -ne $null}
  </code></pre></li>
  </ul>
  
  <p>or</p>
  
  <pre><code>dsquery user "dc=mydomain,dc=local" -disabled | where-object {$_.Common-Name -ne $null}
  </code></pre>
  
  <p>But it didn't help (doesn't work). How can I proceed please?</p>