Categories
Development

Try Catch/Exception for ManagementObjectNotFoundException and ActiveDirectory/Outlook

This might be a pretty basic question, but i haven’t seen it on the forms. Bear with me i’m new to powershell I’m trying to catch this exception(ManagementObjectNotFoundException) when a username is not found in our Active Directory Database. Set-ExecutionPolicy RemoteSigned $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic […]