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-ScriptsTest-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:
7 Responses
Thank you…
Thanks for this
We are now getting a different error against the server the script runs from, for example:
run script on server1, server 1 fails, server 2 passes
run script on server2, server 2 fails, server 1 passes
Mail flow test: WARNING: Connecting to remote server HOSTNAME failed with the following error message : The WinRM client cannot process the request. It cannot determine the content type of the HTTP response from the destination computer. The content type is absent or invalid. 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:scriptshealthcheckTest-ExchangeServerHealth.ps1:452 char:22
+ Remove-PSSession $session.Id
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Remove-PSSession], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.RemovePSSessionCommand
Fail
—— Finishing
Done.
Almost like the server does not understand itself!
Do you have any idea how to resolve this?
Thanks
I ended up installing exchange management tools on another server, then running the script from there. Both servers can then be accessed remotely without errors.
The issue is caused by this line trying to open a remote session to itself
"$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $url -ErrorAction STOP"
thanks so much for your solution , you've saved my day
thanks again
Thanks! It's working fine.
Another reason can be a wrong language.
The script expects the Value "Success", but if you are running the script on a German language Exchange server, you will receive the value "Erfolgreich".
If you look at the script around line 1202, you will find some "if"
if ($testmailflowresult -eq "Erfolgreich" -or $testmailflowresult -eq $success)
Here it checks, if the testmailresult equals "Success" – in our case, we had to change it to "Erfolgreich" to get the magic done! 🙂
Greetz from germany
Bikerpete
https://linuxpeter.de
Many thanks! It worked as described.