depends on whatcaused th eerror since you are ignoring most errors.
When we do a try/catch you MUST also apply a general catch block in case the exception is not parsed as expected.
I understand this. Because I can only trigger 2 error types for this query, I am catching them. I will later add a catch to email me any other unexpected errors.
YUO must also defer to the version of PowerShell. Versions before V5 did not honor many exception types. Look at the selection of PowerShell version you are using in PSS.
I am using PowerShell V5 - 64 bit
PSS uses the native PS engines. It is the engine that executes the code and not PSS.
I'm not sure what to say then. I can reproduce the issue in PSS but when I open the same file in PSISE it works without issue.
Can you please review the attached file to demonstrate? When run in PSISE it runs without issue. With PSS 2015 4.2.89 I receive this error.
>> Debugging (UserTest.ps1) Script...
>> Platform: V5 64Bit (STA)
UserTest.ps1 (147, 10): ERROR: At Line: 147 char: 10
ERROR: + ... catch [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundEx ...
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: Unable to find type [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException].
ERROR:
UserTest.ps1 (184, 10): ERROR: At Line: 184 char: 10
ERROR: + catch [Microsoft.ActiveDirectory.Management.ADException]
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: Unable to find type [Microsoft.ActiveDirectory.Management.ADException].
ERROR: + CategoryInfo : ParserError: (:) [], ParseException
ERROR: + FullyQualifiedErrorId : TypeNotFound