I have an If statement in my script checking if an AD Object already exists. However, none of these evaluations prevent the host from printing the undesired evaluation "Directory object not found."
!$(Get-ADObject -Identity $ImportedObject.DistinguishedName -ErrorAction SilentlyContinue)
[void](!$(Get-ADObject -Identity $ImportedObject.DistinguishedName))
!$($(Get-ADObject -Identity $ImportedObject.DistinguishedName) | Out-Null)
$ErrorAction = $CurrentErrorAction
$ErrorAction = "SilentlyContinue"
!$(Get-ADObject -Identity $ImportedObject.DistinguishedName)
$ErrorAction = $CurrentErrorAction