Problem
You attempt to run the Test-ExchangeServerHealth.ps1 health check script found at the following Microsoft TechCenter:
Generate Health Report for an Exchange Server 2016/2013/2010 Environment
https://gallery.technet.microsoft.com/office/Generate-Health-Report-for-19f5fe5f
… but notice that the report generated is indicating that the mail flow test is failing for your Exchange servers:
Executing the cmdlet interactively in the console displays the following error:
------ Checking CONTOSOBMEXMB01
DNS Check: Pass
Ping Check: Pass
Uptime (hrs): 571
Server version: Exchange 2016
Roles: Mailbox
Mailbox Server Role Services: Pass
Client Access Server Role Services: Pass
Unified Messaging Server Role Services: Pass
Hub Transport Server Role Services: Pass
Total Queue: 0
Mailbox databases mounted: Pass
MAPI connectivity: Success
Mail flow test: WARNING: Connecting to remote server webmail.contoso.com failed with the following error message
: WinRM cannot
process the request. The following error occurred while using Kerberos authentication: Cannot find the computer
webmail.contoso.com. Verify that the computer exists on the network and that the name provided is spelled
correctly. For more information, see the about_Remote_Troubleshooting Help topic.
WARNING: Cannot validate argument on parameter 'Session'. The argument is null or empty. Provide an argument that is
not null or empty, and then try the command again.
Remove-PSSession : Cannot validate argument on parameter 'Id'. The argument is null. Provide a valid value for the
argument, and then try running the command again.
At C:\PS-Scripts\Test-ExchangeServerHealth.ps1:450 char:22
+ Remove-PSSession $session.Id
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Remove-PSSession], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.RemovePSSessionCommand
Fail
Manually executing the Test-Mailflow cmdlet on the servers complete without any issues.
Solution
One of the reasons why this error would be thrown is if you have entered the FQDN that represents your load balanced CAS servers for the PowerShell (Default Web Site) Internal URL field:
Changing the field as shown in the screenshot above causes the script to connect to the virtual name to execute PowerShell cmdlets, which is what causes the following error which complains that the the virtual name does not map to a computer account in Active Directory to be thrown:
Mail flow test: WARNING: Connecting to remote server webmail.contoso.com failed with the following error message: WinRM cannot
process the request. The following error occurred while using Kerberos authentication: Cannot find the computer
webmail.contoso.com. Verify that the computer exists on the network and that the name provided is spelled
correctly.
To correct the issue, change the Internal URL field back to the internal FQDN name of the server: