Connecting to Outlook: Connection Testing Script

Modified on Mon, 01 May 2023 at 06:20 AM

The following Powershell script tests a connection to Outlook.
$sw = [System.Diagnostics.Stopwatch]::StartNew()

$outlook = [Runtime.Interopservices.Marshal]::GetActiveObject('Outlook.Application') 

$selection = $outlook.ActiveExplorer().Selection[1]

$convo = $selection.GetConversation()

$root = $convo.GetRootItems()



To run this script, do the following:
1.  Open Microsoft Outlook and select an email.
2.  Open PowerShell_ISE on your computer then click on File > New.  Paste this script into the tab that appears and then press F5.

When you run this script, it should complete nearly instantaneously and should show results similar to the following:
If the script takes a long time to execute or returns errors, then this likely means that there is a problem with your Outlook or mailbox configuration.  To resolve that issue, we recommend contacting your IT company and performing the steps below:
1.  Remove and re-add your mailbox from Outlook.  Then retest.
2.  Uninstall and reinstall the latest version of Outlook.  Then retest.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article