Powershell: Get FQDN Hostname

后端 未结 15 1650
长发绾君心
长发绾君心 2021-01-30 12:24

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}
         


        
15条回答
  •  礼貌的吻别
    2021-01-30 13:12

    It can also be retrieved from the registry:

    Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters' |
       % { $_.'NV HostName', $_.'NV Domain' -join '.' }
    

提交回复
热议问题