Add to Technorati Favorites
Welcome to ThePowerShellGuy.com Sign in | Join | Help

Add Extended DNS support to PowerShell in 5 minutes

On the PowerShell Community Extensions (PSCX) site , I found this issue : CREATED ISSUE: Need DNS Query that allows DNS server to be specified .

Good that this is discussed and It is great when this functionality get's added to the PSCX project, but as I could not wait and Keith even mentioned where to "steal" this functionality : C# .NET DNS query component on CodeProject.com

I followed the link downloaded the Demo project, loaded DLL into PowerShell, refreshed my tabcompletion to load the new types and followed example in article meanwhile using the  PowerShell Gadget to mimic it in PowerShell :

And with 5 minutes I was done :

 

I really love this PowerGadget it's great I keep it allway's on top at 40 % Opacity , very handy.

If you did not try yet .be sure to check it out !!

here is the code I used for this example :

[System.Reflection.Assembly]::LoadFile( 'C:\dnsposh\Bdev.Net.Dns.dll')
$r = new-Object Bdev.Net.Dns.Request
$q = new-Object Bdev.Net.Dns.Question("www.microsoft.com",'mx','in')
$r.AddQuestion($q)
[Bdev.Net.Dns.Resolver]::Lookup($r,'213.51.129.37') | % {$_.answers}

 

 

Another library to add to my profile, it's syntax is a bit developer oriented as I need to irst create the Question object and add it to the Request so some wrapup functions around it could be handy, but still withing 5 minutes I got all functionality in the library at hand in PowerShell.

Enjoy,

 

Greetings /\/\o\/\/

Published Tuesday, April 10, 2007 4:19 PM by admin
Filed under: , ,

Comments

# re: Add Extended DNS support to PowerShell in 5 minutes

You can also use get-dns in NetCmdlets to do this:

PS C:\>get-dns microsoft.com MX

PREFERENCE : 10

EXCHANGE   : maila.microsoft.com

Type       : MX

Fields     : {PREFERENCE, EXCHANGE}

Values     : {10, maila.microsoft.com}

Domain     : microsoft.com

TTL        : 3600

PREFERENCE : 10

EXCHANGE   : mailb.microsoft.com

Type       : MX

Fields     : {PREFERENCE, EXCHANGE}

Values     : {10, mailb.microsoft.com}

Domain     : microsoft.com

TTL        : 3600

PREFERENCE : 10

EXCHANGE   : mailc.microsoft.com

Type       : MX

Fields     : {PREFERENCE, EXCHANGE}

Values     : {10, mailc.microsoft.com}

Domain     : microsoft.com

TTL        : 3600

Another example:

PS C:\> get-dns nsoftware.com A

ADDRESS : 216.128.22.18

Type    : A

Fields  : {ADDRESS}

Values  : {216.128.22.18}

Domain  : nsoftware.com

TTL     : 1990

Wednesday, April 11, 2007 12:29 PM by Lance Robinson

# re: Add Extended DNS support to PowerShell in 5 minutes

@ Lance,

yep also a great set of tools, that improve network support for powershell a lot

(if you do not know it yet for a full list see :

http://www.nsoftware.com/powershell/default.aspx

a nice complete suit, but it's now beta but gets, commercial software.

also I did it was nice to do it this way using a library from code project

Greetings /\/\o\/\/

Wednesday, April 11, 2007 5:07 PM by MoW
Anonymous comments are disabled