Connecting to Outlook: Connection Testing Script

Modified on Mon, 1 May, 2023 at 6: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()
$convo.ConversationID

$root = $convo.GetRootItems()

$sw.Stop()

$sw.Elapsed

[System.Threading.Thread]::CurrentThread.ApartmentState
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:
BC92290AA99D473D9741FBA852F6C527
0.019304
STA
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 at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article