Network Scan Procedures

Jul 25, 2013 at 5:34 PM
Edited Jul 26, 2013 at 4:53 PM
Hey Kendal,

This is a great tool, thank you for offering it on CodePlex. This is probably the most thorough SQL Server/Windows Inventory tool I have came across. I am new to PowerShell, but I'm loving it, being that I come from a Unix admin background. At this point in time I don't need to unleash the entire program on the network, however I have been searching for a simple algorithm that will scan the network for unknown SQL Server instances. I have already used Quest Discovery Wizard and some cmd line tools for this, however it seems to only detect stand alone instances. I have quite a few SQL Server instances on vm's. I've been dissecting your code on network scan... Would you be able to provide me with the best way to scan a network for SQL Server Instances on both clustered/vm's and stand alone? In the meantime I am going to keep reviewing your PowerShell script. - Thanks SQLLayman
Aug 7, 2013 at 8:29 PM
Hi SQLLayman,
SQL Power Doc makes use of PowerShell modules and one of the great things about modules is that you can reuse them for your own scripts. In this case the NetworkScan module is what handles the service discovery. Here's a basic example (without any logging) which loads the module and finds SQL Services on your network by querying Active Directory for a list of hosts.
Import-Module -Name NetworkScan
Find-SqlServerService -DnsServer Automatic -DnsDomain Automatic
Remove-Module -Name NetworkScan
The Find-SqlServerService accepts many of the same parameters as the inventory scripts included with SQL Power Doc - you can see the syntax using the Get-Help cmdlet:
Import-Module -Name NetworkScan
Get-Help Find-SqlServerService
Remove-Module -Name NetworkScan
Once you have the list of services you can pipe the output to a CSV, or to Format-Table, or Format-List, or Out-GridView, or use the output in your own custom scripts. Because it's PowerShell you've got lots of options.

Hope this gets you pointed in the right direction!