title: get-aduser -ldapfilter this or that
body: <p>I'm trying to make a function so that I can more quickly lookup somebody's phone number or reverse lookup an extension.  </p>
  
  <p>So far I have this saved as a ps1 file:</p>
  
  <pre><code>$find=$args[0]
  Get-ADUser -properties * -LDAPFilter "(samaccountname*$find*)" | ft samaccountname,Name,telephone number
  Get-ADUser -properties * -LDAPFilter "(telephonenumber=555 555-*$find*)" | ft samaccountname,Name,telephonenumber
  </code></pre>
  
  <p>The code works, but obviously I get red error code for either the first or second condition every time.  I've tried <code>(|(This)(That))</code>, I've tried <code>-erroraction silentlycontinue</code>, I've tried <code>-LDAPFilter (This) -OR (That)</code>.</p>
  
  <p>What I'm ultimately after is a function I can add to my profile, so that I can type either:</p>
  
  <pre><code>lookup ABC
  lookup 2948
  </code></pre>
  
  <p>and it will do a forward lookup or a reverse lookup.  It can be a loose search and return a few too many results if necessary.</p>