Skip to content

Resolve‑DnsName

viscalyxbot edited this page Sep 15, 2025 · 1 revision

SYNOPSIS

Resolve a DNS host name (or dotted IP string) to a single IPv4 address.

SYNTAX

Resolve-DnsName [-HostName] <String> [<CommonParameters>]

DESCRIPTION

Uses the cross-platform .NET System.Net.Dns class to resolve DNS names to IPv4 addresses, providing compatibility across Windows, macOS, and Linux platforms even when the built-in Resolve-DnsName cmdlet is not available. If the input is already a valid IPv4 address, it will be returned as-is.

EXAMPLES

EXAMPLE 1

Resolve-DnsName 'pc.company.local'
192.168.1.42

This example resolves the host name 'pc.company.local' to its IPv4 address.

EXAMPLE 2

Resolve-DnsName '192.168.1.42'
192.168.1.42

This example demonstrates that if the input is already a valid IPv4 address, it is returned without modification.

EXAMPLE 3

Resolve-DnsName 'google.com'
142.250.191.14

This example resolves the public domain 'google.com' to one of its IPv4 addresses.

PARAMETERS

-HostName

Specifies the DNS host name to resolve or an IPv4 address literal. The parameter accepts both fully qualified domain names (FQDN) and simple host names. IPv4 addresses are validated and returned without resolution.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.String

DNS host name or IPv4 address as string.

OUTPUTS

System.String

Returns the first IPv4 address found for the specified host name, or the

original IPv4 address if the input was already a valid IP address. Returns

nothing if resolution fails.

NOTES

This function uses the .NET System.Net.Dns.GetHostAddresses method which provides cross-platform DNS resolution capabilities. Only IPv4 addresses are returned; IPv6 addresses are filtered out.

RELATED LINKS

Clone this wiki locally