A real-world example of where using PowerShell “-Verbose” parameter is more efficient than a Google search.
“Couldn’t connect to the source mailbox.”
Recently I needed to export an Exchange 2010 mailbox to a PST file. I opened my Exchange Management Shell and ran New-MailboxExportRequest, only to get the following error:
[PS] C:\Windows\system32>New-MailboxExportRequest -Mailbox jdoe -FilePath \\FileServer1\Exports\jdoe.pst Couldn't connect to the source mailbox. + CategoryInfo : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException + FullyQualifiedErrorId : C7D44FB7,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest
Why couldn’t it connect to the source mailbox?
To the Internet!
My IT Pro lizard brain kicked in and I automatically Google’d the error message. A search on “Couldn’t connect to the source mailbox.” (in quotes) returned just over a thousand results. The first six were lengthy threads on the TechNet forums, with a lot of back and forth messages trying to troubleshoot someone else’s issue. The first result was talking about Cisco Load Balancers and a Client Access Array, and I can tell you I felt like I was way off mark in my search.
Now, (SPOILER ALERT) I will tell you that further down there were results that ultimately described the same problem I had encountered. However, I only realized that after I resolved my problem and started writing this post.
“-Verbose” parameter for debugging a command
All cmdlets have -Verbose as a standard parameter. A cmdlet author uses Write-Verbose to write messages to the verbose message stream. This stream is used to write information about command processing, useful for debugging the command. Mileage will vary depending on the what the cmdlet does as well as the verbose messaging included by the cmdlet author.
Identifying the cause
I re-ran my cmdlet, this time adding on the -Verbose parameter. The full output is below. You see we now get A LOT more information about what is going on behind the scenes when we run this cmdlet. The key line is 3/4 of the way down where we see our error message but with some pretty important supporting details:
Couldn’t connect to the source mailbox. –>
MapiExceptionProtocolDisabled: Unable to make connection to the server.
[PS] C:\Windows\system32>New-MailboxExportRequest -Mailbox jdoe -FilePath \\FileServer1\Exports\jdoe.pst -Verbose VERBOSE: [13:05:39.956 GMT] New-MailboxExportRequest : Active Directory session settings for 'New-MailboxExportRequest' are: View Entire Forest: 'False', Default Scope: 'tpslabs.net', Configuration Domain Controller: 's1adds1.tpslabs.net', Preferred Global Catalog: 's1adds1.tpslabs.net', Preferred Domain Controllers: '{ s1adds1.tpslabs.net }' VERBOSE: [13:05:39.956 GMT] New-MailboxExportRequest : Runspace context: Executing user: tpslabs.net/Users/LabAdmin, Executing user organization: , Current organization: , RBAC-enabled: Enabled. VERBOSE: [13:05:39.956 GMT] New-MailboxExportRequest : Beginning processing & VERBOSE: [13:05:39.956 GMT] New-MailboxExportRequest : Instantiating handler with index 0 for cmdlet extension agent "Admin Audit Log Agent". VERBOSE: [13:05:39.972 GMT] New-MailboxExportRequest : Current ScopeSet is: { Recipient Read Scope: {{, }}, Recipient Write Scopes: {{, }}, Configuration Read Scope: {{, }}, Configuration Write Scope(s): {{, }, }, Exclusive Recipient Scope(s): {}, Exclusive Configuration Scope(s): {} } VERBOSE: [13:05:39.972 GMT] New-MailboxExportRequest : Searching objects "jdoe" of type "ADUser" under the root "$null". VERBOSE: [13:05:39.987 GMT] New-MailboxExportRequest : Previous operation run on domain controller 's1adds1.tpslabs.net'. VERBOSE: [13:05:39.987 GMT] New-MailboxExportRequest : Searching objects "LargeMailBoxes" of type "MailboxDatabase" under the root "$null". VERBOSE: [13:05:39.987 GMT] New-MailboxExportRequest : Previous operation run on domain controller 's1adds1.tpslabs.net'. VERBOSE: [13:05:39.987 GMT] New-MailboxExportRequest : [DEBUG] MDB f2d1b1c8-f420-4ce4-9489-1dd30032529d found to belong to Site: tpslabs.net/Configuration/Sites/Site1 VERBOSE: [13:05:40.003 GMT] New-MailboxExportRequest : [DEBUG] MRSClient: attempting to connect to 'Exchange1.tpslabs.net' VERBOSE: [13:05:40.705 GMT] New-MailboxExportRequest : [WARNING] Attempt to connect to CAS Server Exchange1.tpslabs.net failed with error: Downlevel clients aren't supported. VERBOSE: [13:05:40.705 GMT] New-MailboxExportRequest : [DEBUG] MRSClient: attempting to connect to 'Exchange2.tpslabs.net' VERBOSE: [13:05:40.720 GMT] New-MailboxExportRequest : [DEBUG] MRSClient: connected to 'Exchange2.tpslabs.net', version 14.3.224.1 caps:07 VERBOSE: [13:05:40.720 GMT] New-MailboxExportRequest : Processing object "RequestGuid (024b5520-d785-4c59-b4fe-dd278508495a), RequestQueue: (f2d1b1c8-f420-4ce4-9489-1dd30032529d)". VERBOSE: [13:05:40.798 GMT] New-MailboxExportRequest : Couldn't connect to the source mailbox. --> MapiExceptionProtocolDisabled: Unable to make connection to the server. (hr=0x80004005, ec=2008) Diagnostic context: Lid: 59431 EMSMDB.EcDoConnectEx called [length=94] Lid: 34855 EMSMDB.EcDoConnectEx returned [ec=0x7D8][length=56][latency=0] Lid: 59505 StoreEc: 0x7D8 Lid: 52465 StoreEc: 0x7D8 Lid: 60065 Lid: 33777 StoreEc: 0x7D8 Lid: 59805 Lid: 52209 StoreEc: 0x7D8 Lid: 56583 Lid: 52487 StoreEc: 0x7D8 Lid: 19778 Lid: 27970 StoreEc: 0x7D8 Lid: 17730 Lid: 25922 StoreEc: 0x7D8 VERBOSE: [13:05:40.798 GMT] New-MailboxExportRequest : Admin Audit Log: Entered Handler:OnComplete. Couldn't connect to the source mailbox. + CategoryInfo : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException + FullyQualifiedErrorId : 531DCDBD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest
Mailbox Feature ‘MAPI’ was disabled
Sure enough, if I go and look at the mailbox properties, I see that MAPI had been disabled.
I re-enabled MAPI for the mailbox and re-ran my original export attempt (no -Verbose parameter). It now ran successfully and queued the export.
[PS] C:\Windows\system32>New-MailboxExportRequest -Mailbox jdoe -FilePath \\FileServer1\Exports\jdoe.pst Name Mailbox Status ---- ------- ------ MailboxExport1 tpsplabs.net/Users/jdoe Queued
Takeaways
- The next time you run into a PowerShell cmdlet error, resist the temptation to Google a vague error message and re-run the cmdlet with the -Verbose parameter instead.
- When writing your own functions or cmdlets, use Write-Verbose to add verbose messages to aid troubleshooting.
Reference
- technet.microsoft.com
Joe says
Thank you very much!
wysky says
Sure! It was helpful!