Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
powershell:如何以dns格式检索计算机名_Powershell_Dns_Wmi - Fatal编程技术网

powershell:如何以dns格式检索计算机名

powershell:如何以dns格式检索计算机名,powershell,dns,wmi,Powershell,Dns,Wmi,我想在windows 7计算机上检索当前计算机名,例如computername.companyname.local。如何做到这一点 我不是在一台有真正域名的机器上运行,所以我不能100%确定,但我认为这对你来说可能有用: get-wmiobject Win32_NetworkAdapterConfiguration | where {$_.DNSHostName} | select @{n="FQDN";e={$_.DNSHostName + "." + $_.DNSDomain } } | f

我想在windows 7计算机上检索当前计算机名,例如computername.companyname.local。如何做到这一点

我不是在一台有真正域名的机器上运行,所以我不能100%确定,但我认为这对你来说可能有用:

get-wmiobject Win32_NetworkAdapterConfiguration | where {$_.DNSHostName} | select @{n="FQDN";e={$_.DNSHostName + "." + $_.DNSDomain } } | format-table
对于我的Thinkpad笔记本电脑,这会返回如下内容:

FQDN
----
t500.home

要将其作为字符串返回,请执行以下操作:

gwmi Win32_ComputerSystem| %{$_.DNSHostName + '.' + $_.Domain}

使用framework.NET,这在我的域上运行:

([system.net.dns]::GetHostByName("localhost")).hostname
您也可以在下面找到信息(但必须重新生成):

[System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties()