Take the 2-minute tour ×

I want to retreive the current computer name as an FQDN on a windows 7 machine e.g. computername.companyname.local. Can anyone tell me how to achieve this please?

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

To return it as a string:

gwmi Win32_ComputerSystem| %{$_.DNSHostName + '.' + $_.Domain}
share|improve this answer
add comment

Using framework .NET this is working on my domain :


You can also find the information here under (but you have to rebuild it):

share|improve this answer
add comment

I'm not running on a machine with a real domain, so I can't be 100% sure, but I think that this could work for you:

get-wmiobject Win32_NetworkAdapterConfiguration | where {$_.DNSHostName} | select @{n="FQDN";e={$_.DNSHostName + "." + $_.DNSDomain } } | format-table

For my Thinkpad laptop, this returns something like this:

share|improve this answer
add comment

Your Answer


