Hi JrouziesM
Happy New Year and apologies for not getting back to you sooner.
In Powershell Script connecting to MFA enabled Exchange Online using a certificate thumbprint (i.e. no password or user interaction or pop up) and then executing the following statement works fine (before disconnection of course);
Get-EXOMailbox -UserPrincipalName devade@aircharterdev.co.uk -Properties DeliverToMailboxAndForward, ForwardingAddress | Out-String
As I said, in C# code I am able to connect to Exchange Online (using the solution you gave me on 16th December with no password or user interaction or pop up) but get that strange error I mentioned above on 17th Dec (about System Notification Events not being supported by the Current Context) when I execute the following;
session.AddScript("Get-EXOMailbox -UserPrincipalName devade@aircharterdev.co.uk -Properties DeliverToMailboxAndForward, ForwardingAddress | Out-String");
Collection<PSObject> results = session.Invoke();
However, following your advice I tried the same in C# code using the old cmdlet Get-Mailbox and the code (below) works perfectly fine;
session.AddScript($"Get-Mailbox 'devade@aircharterdev.co.uk' | Format-List DeliverToMailboxAndForward, ForwardingAddress | Out-String");
Collection<PSObject> results = session.Invoke();
(basically the code correctly returns that the mailbox has forwarding enabled and the email address the forwarding is set to).
So The_Exchange_Team it would seem the issue is with the new cmdlet Get-EXOMailbox. For the time being I can create my solution using the Get-Mailbox and Set-Mailbox cmdlets but I am aware that they are https://docs.microsoft.com/en-us/powershell/exchange/exchange-online-powershell-v2?view=exchange-ps. As such The_Exchange_Team are you able to a) confirm whether these older cmdlets are actually depreciated or will continue to be supported and b) help out at all with my issue with Get-EXOMailbox working fine in PowerShell script but not inside a C# PowerShell session?
Thanks in advance, Ade