title: comparing domain accounts in two DCs - how to exclude not found messages from get-ADUser?
body: <p>I'm comparing Domainaccounts between two different domains of which some have the same SamAccountName on both domains. Everything works great except that my script generates an error everytime the User is not found on the 2nd domain.</p>
  
  <p>Is there a way to eliminate the output of the <code>Get-ADUser : Cannot find an object with identity: 'duda</code> and maybe writing a single Error via <code>write-host</code> instead?
  I have also used the <code>-ErrorAction SilentlyContinue</code> but still get the Error</p>
  
  <p>Here's a snippet of my actual code for this:</p>
  
  <pre><code>$user_id = Get-ADUser -Filter * -SearchBase $SearchBase | Select-Object SamAccountName
  
  $readthat = $user_id | Foreach-Object {
  $user1 = Get-ADUser -Identity $_.SamAccountName -Properties $attributes
  $user2 = Get-ADUser -Identity $_.SamAccountName -Properties $attributes -Credential $WPS_AdminCredentials -Server $dc2 -ErrorAction SilentlyContinue
  
  if ($user1.SamAccountName -eq $user2.SamAccountName) {.....
  </code></pre>