This is part of my script:
Trap {Write-Output \'Authentication Error trapped\'}
Try {New-Object System.DirectoryServices.DirectoryEntry $strDistinguishedName,$st
I had a similar error and the comment from @TessellatingHeckler helped me.
Piping the result to Out-Null
fixed it for me. So you can try the following:
Trap {Write-Output 'Authentication Error trapped'}
Try {New-Object System.DirectoryServices.DirectoryEntry $strDistinguishedName,$strUsername,$strPlainPassword -ErrorAction stop | Out-Null}
Catch{Write-Output 'Authentication Error catched'}
Write-Output 'Script has not trapped nor catched the error but continued'