When running the following PowerShell code:
$Outlook = New-Object -ComObject Outlook.Application
$Stores = $Outlook.Session.Stores
$Accounts = $Outlook.Session.Accounts
$Accounts | Select-Object DisplayName, UserName, SmtpAddress, ExchangeMailboxServerName, ExchangeMailboxServerVersion
A security warning pops-up:
According to Microsoft there are ways around this. For instance, one can Create a COM Add-in for Outlook
instead of using the Outlook COM Object
as explained here. Another example of a custom COM Add-in for Outlook
is posted here on StackOverflow but for another language.
Using Globals.ThisAddIn.Application
should make this possible, No? Can someone explain to me how this is done with PowerShell? It would be great if we could avoid this pop-up as it will only confuse users.