microsoft / CSS-Exchange

Exchange Server support tools and scripts
MIT License
1.22k stars 341 forks source link

[Issue] SourceSideValidations fails if server short name does not resolve #1902

Open bill-long opened 11 months ago

bill-long commented 11 months ago
[exch1] Connecting to remote server exch1 failed with the following error message : A specified logon
session does not exist. It may already have been terminated. For more information, see the 
about_Remote_Troubleshooting Help topic.

The script attempts to Import-PSSession as follows:

Import-PSSession (New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri [http://$Server/powershell]http://$Server/powershell -Authentication Kerberos)

$Server is the short name of the server, and this error is the result when the short name does not resolve. Changing it to the FQDN fixes it, as long as the FQDN does resolve.

Need to evaluate whether we should change the script to use FQDN instead of short name.

bill-long commented 10 months ago

I'm not sure how to determine the FQDN of the local machine if the short name does not resolve. For example, this StackOverflow answer says that [System.Net.Dns]::GetHostByName($env:computerName) is the correct way to get the FQDN of the local machine, but that relies on DNS. If DNS can resolve the short name to the correct FQDN, we won't hit this issue in the first place.