OpsaC - Operating as PowerShell code
published: September 28, 2019 author: Tinu tags: PowerShell categories: PowerShell-Network
A fast Name resolution with System.Net.Dns
Resolve the Hostname to IPAddresses
[System.Net.Dns]::GetHostByName($Hostname)
HostName Aliases AddressList
-------- ------- -----------
google.com {} {2a00:1450:400a:803::200e, 172.217.168.14}
Resolve the IPAddress to HostName
[System.Net.Dns]::GetHostByAddress($IPv4Address)
HostName Aliases AddressList
-------- ------- -----------
zrh11s03-in-f14.1e100.net {} {172.217.168.14}
[System.Net.Dns]::GetHostByAddress($IPv6Address)
HostName Aliases AddressList
-------- ------- -----------
zrh04s15-in-x0e.1e100.net {} {2a00:1450:400a:803::200e}
Name resolution with my Module PsNetTools, based on System.Net.Dns
Resolve the Hostname to IPAddresses
Test-PsNetdig -Destination $Hostname
Succeeded : True
InputString : google.com
Destination : google.com
IpV4Address : {216.58.215.238}
IpV6Address : {2a00:1450:400a:803::200e}
TimeMs : 131
Resolve the IPAddress to HostName
Test-PsNetdig -Destination $IPv4Address
Succeeded : True
InputString : 216.58.215.238
Destination : zrh11s02-in-f14.1e100.net
IpV4Address : {216.58.215.238}
IpV6Address :
TimeMs : 4573
Test-PsNetdig -Destination $IPv6Address
Succeeded : True
InputString : 2a00:1450:400a:803::200e
Destination : zrh04s15-in-x0e.1e100.net
IpV4Address :
IpV6Address : {2a00:1450:400a:803::200e}
TimeMs : 33
Name resolution with the Resolve-DnsName cmdlet
Resolve the Hostname to IPAddresses
Resolve-DnsName -Name $Hostname
Name Type TTL Section IPAddress
---- ---- --- ------- ---------
google.com AAAA 190 Answer 2a00:1450:400a:803::200e
google.com A 181 Answer 172.217.168.78
Resolve the IPAddress to HostName
Resolve-DnsName -Name $IPv4Address
Name Type TTL Section NameHost
---- ---- --- ------- --------
78.168.217.172.in-addr.arpa PTR 81590 Answer zrh04s15-in-f14.1e100.net
Resolve-DnsName -Name $IPv6Address
Name Type TTL Section NameHost
---- ---- --- ------- --------
E.0.0.2.0.0.0.0.0.0.0.0.0.0.0. PTR 56066 Answer zrh04s15-in-x0e.1e100.net
0.3.0.8.0.A.0.0.4.0.5.4.1.0.0.
A.2.ip6.arpa
Dns Class on Microsoft Docs.
Resolve-DnsName on Microsoft Docs.
PsNetTools on github.