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}
How about this
$FQDN=[System.Net.Dns]::GetHostByName($VM).Hostname.Split('.') [int]$i = 1 [int]$x = 0 [string]$Domain = $null do { $x = $i-$FQDN.Count $Domain = $Domain+$FQDN[$x]+"." $i = $i + 1 } until ( $i -eq $FQDN.Count ) $Domain = $Domain.TrimEnd(".")