commands

^

Resolve-DbaNetworkName

Author Klaas Vandenberghe (@PowerDBAKlaas) , Simone Bizzotto (@niphold)
Availability Windows, Linux, macOS

 

Synopsis

Returns information about the network connection of the target computer including NetBIOS name, IP Address, domain name and fully qualified domain name (FQDN).

Description

Retrieves the IPAddress, ComputerName from one computer. The object can be used to take action against its name or IPAddress.

First ICMP is used to test the connection, and get the connected IPAddress.

Multiple protocols (e.g. WMI, CIM, etc) are attempted before giving up.

Important: Remember that FQDN doesn't always match "ComputerName dot Domain" as AD intends. There are network setup (google "disjoint domain") where AD and DNS do not match. "Full computer name" (as reported by sysdm.cpl) is the only match between the two, and it matches the "DNSHostName" property of the computer object stored in AD. This means that the notation of FQDN that matches "ComputerName dot Domain" is incorrect in those scenarios. In other words, the "suffix" of the FQDN CAN be different from the AD Domain.

This cmdlet has been providing good results since its inception but for lack of useful names some doubts may arise. Let this clear the doubts:

  • InputName: whatever has been passed in
  • ComputerName: hostname only
  • IPAddress: IP Address
  • DNSHostName: hostname only, coming strictly from DNS (as reported from the calling computer)
  • DNSDomain: domain only, coming strictly from DNS (as reported from the calling computer)
  • Domain: domain only, coming strictly from AD (i.e. the domain the ComputerName is joined to)
  • DNSHostEntry: Fully name as returned by DNS [System.Net.Dns]::GetHostEntry
  • FQDN: "legacy" notation of ComputerName "dot" Domain (coming from AD)
  • FullComputerName: Full name as configured from within the Computer (i.e. the only secure match between AD and DNS)

So, if you need to use something, go with FullComputerName, always, as it is the most correct in every scenario.

Syntax

Resolve-DbaNetworkName
    [[-ComputerName] <DbaInstanceParameter[]>]
    [[-Credential] <PSCredential>]
    [-Turbo]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Resolve-DbaNetworkName -ComputerName sql2014

Returns a custom object displaying InputName, ComputerName, IPAddress, DNSHostName, DNSDomain, Domain, DNSHostEntry, FQDN, DNSHostEntry for sql2014

Example: 2
PS C:\> Resolve-DbaNetworkName -ComputerName sql2016, sql2014

Returns a custom object displaying InputName, ComputerName, IPAddress, DNSHostName, DNSDomain, Domain, DNSHostEntry, FQDN, DNSHostEntry for sql2016 and sql2014

Example: 3
PS C:\> Get-DbaRegServer -SqlInstance sql2014 | Resolve-DbaNetworkName

Returns a custom object displaying InputName, ComputerName, IPAddress, DNSHostName, DNSDomain, Domain, DNSHostEntry, FQDN, DNSHostEntry for all SQL Servers returned by Get-DbaRegServer

Example: 4
PS C:\> Get-DbaRegServer -SqlInstance sql2014, sql2016\sqlexpress | Resolve-DbaNetworkName

Returns a custom object displaying InputName, ComputerName, IPAddress, DNSHostName, DNSDomain, Domain, DNSHostEntry, FQDN, DNSHostEntry for all SQL Servers returned by Get-DbaRegServer

Optional Parameters

-ComputerName

The target SQL Server instance or instances. This can be the name of a computer, a SMO object, an IP address or a SQL Instance.

Alias
Required False
Pipeline true (ByValue)
Default Value $env:COMPUTERNAME
-Credential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential). Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported. For MFA support, please use Connect-DbaInstance.

Alias
Required False
Pipeline false
Default Value
-Turbo

Resolves without accessing the server itself. Faster but may be less accurate because it relies on DNS only, so it may fail spectacularly for disjoin-domain setups. Also, everyone has its own DNS (i.e. results may vary changing the computer where the function runs)

Alias FastParrot
Required False
Pipeline false
Default Value False
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting. Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False

 

Want to see the source code for this command? Check out Resolve-DbaNetworkName on GitHub.
Want to see the Bill Of Health for this command? Check out Resolve-DbaNetworkName.