I want to retrieve the FQDN name of windows server via powershell script. I have found 2 solution so far:
$server = Invoke-Command -ScriptBlock {hostname}
It can also be retrieved from the registry:
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters' | % { $_.'NV HostName', $_.'NV Domain' -join '.' }