new-blogentry -topic "Powershell and More"

My observations about Powershell, Windows, System Center and life.

Recent comments

Tags

Don't show

    Disclaimer

    Any opinions expressed herein are completely accidental. But if one happens to slip in, it represents my own personal opinion and NO one elses. I'm also not concerned with changing anyone elses opinion, so any rants about anything presented on this site are likely to be 100% ignored.

    © Copyright 2010

    Get-NBTHosts

    * This is a repost from my original blog location *

    I've been a long time user of a very useful cmd line utility called NBTScan. NBTScan is similar to the Windows builtin cmd line utility NBTSTAT, but can operate on a range of IP addresses instead of a single IP. Using NBTscan, you can get a list of Windows machines that are configured to respond to NETBIOS and aren't behind a firewall. You can find some more information about NBTScan at http://www.unixwiz.net/tools/nbtscan.html, but that's an older version that doesn't support a couple of required parameters for this script. For the newest version that I've been able to find, look at http://inetcat.net/software/nbtscan.html.

    Here's a script I use to wrap the output into Powershell friendly custom objects.

    function Get-NBTHosts {

        param($iprange)

     

        if (!$iprange) {

          write-Host "You must specify an -iprange in CDIR notation.`r`n  Example: 192.168.1.0/24 "

          return

        }

     

       $iprange | % { nbtscan -t 500 -m 1 -s : $_  2>$null | % {

     

                $out = 1 |Select-Object IPAddress,Name,User,MACAddress

               

                $a = $_.split(":")

               

                $out.IPAddress = $a[0].trim()

                $out.Name = $a[1].replace("IS~","").trim()

                $out.User = $a[3].trim()

                $out.MACAddress = $a[4].trim()

               

                write-Output $out

            }

        }  

    }

    Example:

    PS D:\ps> Get-NBTHosts 10.150.5.0/24
    IPAddress                     Name                          User                          MACAddress
    ---------                     ----                          ----                          ----------
    10.150.5.3                    HHHSSC65SP5                   <unknown>                     XX-XX-XX-XX-XX-XX
    10.150.5.6                    HHHSQL                        <unknown>                     XX-XX-XX-XX-XX-XX
    10.150.5.8                    HHHFDBSVR                     <unknown>                     XX-XX-XX-XX-XX-XX
    PS D:\ps> 
    

    You'll need nbtscan and cygwin1.dll somewhere in your path so that Get-NBTHosts can find it or modify the script to point directly to location of nbtscan.


    Categories: powershell
    Posted by gaurhoth on Friday, October 05, 2007 3:48 AM
    E-mail | Permalink | Comments (34) | Post RSSRSS comment feed

    Related posts

    Comments

    Andy Schneider us

    Tuesday, April 01, 2008 7:37 AM

    Andy Schneider

    This is sweet. Thanks for the info on the tool. The PS wrapper is great too. Much appreciated.

    Andy

    cheap microwave ovens gb

    Tuesday, October 06, 2009 1:09 PM

    cheap microwave ovens

    Great. Love this post

    small dog shock collar gb

    Tuesday, October 06, 2009 4:13 PM

    small dog shock collar

    great information thanks

    best toaster ovens gb

    Wednesday, October 07, 2009 10:52 AM

    best toaster ovens

    Awesome info. thanks

    outdoor fireplaces

    Wednesday, October 21, 2009 4:20 AM

    outdoor fireplaces

    I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

    mandy david

    Friday, November 27, 2009 12:23 AM

    mandy david

    Very interesting clock.. I really love reading this articles.

    play tetris

    Monday, November 30, 2009 4:37 AM

    play tetris

    Hey webmaster, thank you for sharing this information..., i found it awesome. Cheers, Aysu!!!

    tetris game

    Monday, November 30, 2009 5:58 AM

    tetris game

    Hey webmaster, amazing blog post! Pls continue this awesome work..

    defense games

    Wednesday, December 02, 2009 3:57 PM

    defense games

    I really loved this gorgeous blog post. Please keep them coming. Regards from John!

    william

    Saturday, December 05, 2009 9:58 PM

    william

    Thank you, you answered the question I have been searching for which was whether or not to place keywords when blog commenting.

    uni bet

    Sunday, December 06, 2009 4:28 PM

    uni bet

    Considerably, the article is actually the best on this laudable topic. I harmonise with your conclusions and will eagerly look forward to your incoming updates. Saying thanks will not just be adequate, for the tremendous lucidity in your writing. I will instantly grab your rss feed to stay informed of any updates. Gratifying work and much success in yourbusiness efforts!

    Acai Berry us

    Monday, December 07, 2009 12:14 AM

    Acai Berry

    Excellent post.This was actually what I was looking for, and I am glad that I finally came here! Thanks for sharing the such information with us.

    Credit Card Debt Solutions gb

    Monday, December 07, 2009 3:01 PM

    Credit Card Debt Solutions

    Just found your blog on Technorati & Digg upcomming news feeds and read a few of your other posts.

    Ezine gb

    Monday, December 07, 2009 5:53 PM

    Ezine

    I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the latest stuff you post.

    Music downloads gb

    Tuesday, December 08, 2009 7:59 PM

    Music downloads

    I just couldnt leave your website before saying that I really enjoyed the quality information you offer to your visitors... Will be back often to check up on new stuff you post!

    uni bet

    Wednesday, December 09, 2009 3:21 PM

    uni bet

    Well, the post is actually the greatest on this worthy topic. I concur with your conclusions and will thirstily look forward to your upcoming updates. Saying thanks will not just be adequate, for the exceptional clarity in your writing. I will directly grab your rss feed to stay privy of any updates. Gratifying work and much success in your business endeavors!

    casino en ligne

    Wednesday, December 09, 2009 8:22 PM

    casino en ligne

    Intimately, the article is really the sweetest on this worthwhile topic. I harmonise with your conclusions and will eagerly look forward to your approaching updates. Just saying thanks will not just be adequate, for the phenomenal clarity in your writing. I will immediately grab your rss feed to stay abreast of any updates. Fabulous work and much success in yourbusiness efforts!

    Kim us

    Thursday, December 10, 2009 2:13 PM

    Kim

    Thanks for talking about NBTScan. I'd never heard of it before so what to thank you for taking the time to write this blog post.

    California Sexual Harassment Lawyers us

    Friday, December 11, 2009 6:38 AM

    California Sexual Harassment Lawyers

    Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It's always nice when you can not only be informed, but also entertained! I'm sure you had fun writing this article.



    Regards
    Hardy







    Casie Duckworth us

    Friday, December 11, 2009 11:21 PM

    Casie Duckworth

    Cant believe that I?m the first one to digg this? Anyway, I did. Thanks for this awesome information.

    Gucci Shoes

    Saturday, December 12, 2009 7:49 PM

    Gucci Shoes

    Could you please provide more information on this subject? By the way your site is amazing. Greets!!

    ed hardy

    Saturday, December 12, 2009 7:49 PM

    ed hardy

    Could you please provide more information on this subject? By the way your site is amazing. Greets!!

    solde

    Monday, December 14, 2009 9:33 PM

    solde

    I love that, I wish I could go and see it Thank YOu Admin

    Nike Obasola us

    Thursday, December 17, 2009 5:09 AM

    Nike Obasola

    Ultimately, an issue that I am fervent about. I have looked for information of this topic for the last several hours. Your site is greatly treasured.

    where to buy fioricet us

    Monday, December 21, 2009 3:55 AM

    where to buy fioricet

    There are certainly a lot of details like that to take into consideration. That is a great point to bring up. I offer the thoughts above as general inspiration but clearly there are questions like the one you bring up where the most important thing will be working in honest good faith. I don?t know if best practices have emerged around things like that, but I am sure that your job is clearly identified as a fair game.

    usa online casinos art us

    Monday, December 21, 2009 8:55 AM

    usa online casinos art

    This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It is the old what goes around comes around routine. Did you acquired lots of links and I see lots of trackbacks??

    tweetadder us

    Tuesday, December 22, 2009 6:25 PM

    tweetadder

    Great post! I am just starting out in community management/marketing media and trying to learn how to do it well - resources like this article are incredibly helpful. As our company is based in the US, it?s all a bit new to us. The example above is something that I worry about as well, how to show your own genuine enthusiasm and share the fact that your product is useful in that case.

    Peter us

    Tuesday, December 22, 2009 6:42 PM

    Peter

    In general I do not make a comment on blogs, but I have to mention that this post really forced me to do so. Really nice post!

    Scott us

    Wednesday, December 23, 2009 3:36 PM

    Scott

    It’s nice to finally locate a website where the blogger knows really well about his subject.

    Scotty us

    Thursday, December 24, 2009 7:20 AM

    Scotty

    I visit your web site from time to time and I must mention that I like your template!

    Leonel us

    Saturday, December 26, 2009 7:31 AM

    Leonel

    You made numerous nice ideas there. I done a search on the issue and learnt nearly all peoples will agree with your blog.

    gold coins us

    Saturday, December 26, 2009 11:06 AM

    gold coins

    Resources like the one you mentioned here will be very useful to me! I will post a link to this page on my blog. I am sure my visitors will find that very useful.

    oregon bankruptcy lawyers us

    Sunday, December 27, 2009 12:11 PM

    oregon bankruptcy lawyers

    Well, this is my first visit to your blog! We are a group of volunteers and starting a new initiative in a community in the same niche. Your blog provided us valuable information to work on. You have done a marvellous job!

    hp printer us

    Sunday, December 27, 2009 1:54 PM

    hp printer

    This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work.

    Add comment


    (Will show your Gravatar icon)  

    [b][/b] - [i][/i] - [u][/u]- [quote][/quote]