function Get-FullyQualifiedServerName { <# .SYNOPSIS Returns the fully qualified server name #> param ( ) $globalIPProperties = [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties(); # If no domain is present, return just the hostname. If there is a domain, . append it after the hostname if ($globalIPProperties.DomainName.length -gt 0) { $qualifiedServerName = "{0}.{1}" -f $globalIPProperties.HostName, $globalIPProperties.DomainName; } else { $qualifiedServerName = $globalIPProperties.HostName; } return $qualifiedServerName }