Get Computer Fully Qualified Domain Name ( Using Powershell )

Background

Recently I needed to confirm a remote’s computer fully qualified domain name.

Options

GUI

Win OS

Outline

  1. Access Control Panel \ System and Security \ System
  2. The computer name will be listed
    • Group Box:- Computer name, domain, and workgroup settings
    • Item:- Full Computer Name

Images

Image – View basic information about your computer

Console

Script

Command

ipconfig
Outline

Runs commands on local and remote computers.

Syntax
ipconfig
Sample
ipconfig /all
Output – Image

Explanation

What you want to look closely at are:-

  1. Host Name
  2. Primary DNS Suffix

Powershell

Invoke-Command
Outline

Runs commands on local and remote computers.

Syntax
powershell -command "Invoke-Command -ComputerName <remoteComputer> -ScriptBlock { ([System.Net.Dns]::GetHostByName(('localhost'))).Hostname }"
Sample
powershell -command "Invoke-Command -ComputerName dbSales -ScriptBlock { ([System.Net.Dns]::GetHostByName(('localhost'))).Hostname }"

Caveat

User Fully Qualified Domain Name

The most well intentioned people get Computer Fully Qualified Domain Name and User Fully Qualified Domain Name tongue tied.

They will tell you access console and read the environment variable using “set user“.

Or more specifically, issue “set USERDNSDOMAIN“.

Microsoft specifically notes that which is returned is USERDNSDOMAIN.

And, not the computerDNSDOMAIN.

 

References

  1. Microsoft
    • Powershell
      • Learn / PowerShell / Scripting / Reference / Microsoft.PowerShell.Core
        • Invoke-Command
          Link

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s