PowerShell for Windows Admins

Jan 26 2016   8:21AM GMT

FQDN

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Tags:
Powershell

How do you find the FQDN of the machine you’re using.  The simplest way is to combine a couple of environmental variables:

PS> “$env:COMPUTERNAME.$env:USERDNSDOMAIN”
SERVER02.MANTICORE.ORG

If you like using CIM (and who doesn’t) you can try this

PS> Get-CimInstance -ClassName Win32_ComputerSystem |
>> select @{N=’FQDN’; E={“$($_.DNSHostName).$($_.Domain)”}}
>>

FQDN
—-
server02.Manticore.org

This could easily be used for remote machines as well by adding the –ComputerName parameter to Get-CimInstance

If you want to go down the .NET route you have:

PS> [System.Net.Dns]::GetHostByName(”).HostName
server02.Manticore.org

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: