



PowerShell uses the power of .Net Framework thus you can leverage .Net classes in your PowerShell scripts.
In this example I’ll show you how you can perform DNS lookups using the Net.Dns class :
[System.Net.Dns]::GetHostentry(“blog.paux.fr”)
The result will be (depending if your input is a A or CNAME) :
HostName Aliases AddressList
-------- ------- -----------
dedibox2.jeanb-net.com {} {88.191.92.204}
You can obviously pipe a list of hostname to this command and if you need to keep the original name you can add it to the resulted object and display it in a grid (new to PS2.0 !):
gc .\hosts.txt |% { [System.Net.Dns]::GetHostentry($_) | Add-Member -Name Host -MemberType NoteProperty -Value $_ -PassThru } | Select Host,AddressList | out-gridview
You can of course do the same with an IP address (or an IPv6 address):
[System.Net.Dns]::GetHostentry("2001:4860:a005::68")
The class in .Net Framework stay basic so you can’t resolve NS, SOA, MX or TXT records for example but you can try to use other classes as this implementation of a resolver in C# or using this one (that use the internal DNS resolver of Windows)


More Options ...
Categories
Tag Cloud
Blog RSS
Comments RSS

Void « Default
Life
Earth
Wind
Water
Fire
Light 