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}
I use the following syntax :
$Domain=[System.Net.Dns]::GetHostByName($VM).Hostname.split('.') $Domain=$Domain[1]+'.'+$Domain[2]
it does not matter if the $VM is up or down...