List SQL Server Instances using the Registry


I read this interesting article on using PowerShell and the registry, and thought I would modify his information a bit to list the SQL Server Instances on a box. The interesting thing about listing instances this was is that you can touch remote machines, find the instances when they are off and so on. Anyway, here’s the scriptlet I used to find the Instances on my system:

$MachineName = '.'

$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $MachineName)

$regKey= $reg.OpenSubKey("SOFTWARE\\Microsoft\\Microsoft SQL Server\\Instance Names\\SQL" )

$regkey.GetValueNames()

You can read more of his article to find out the reason for the remote registry call and so forth – there are also security implications here for being able to read the registry.

Script Disclaimer, for people who need to be told this sort of thing:

Never trust any script, including those that you find here, until you understand exactly what it does and how it will act on your systems. Always check the script on a test system or Virtual Machine, not a production system. Yes, there are always multiple ways to do things, and this script may not work in every situation, for everything. It’s just a script, people. All scripts on this site are performed by a professional stunt driver on a closed course. Your mileage may vary. Void where prohibited. Offer good for a limited time only. Keep out of reach of small children. Do not operate heavy machinery while using this script. If you experience blurry vision, indigestion or diarrhea during the operation of this script, see a physician immediately.


Comments (7)

  1. You will be rewarded at least 90 cash each ranges, with additional strikes and bombs, it
    is best to be able to earn at the very least a
    hundred coins per stage.

  2. I pay a visit each day some blogs and information sites to read articles, however this webpage provides quality based writing.

  3. Wow, that’s what I was looking for, what a material! existing here at this website, thanks admin of this website.

  4. Beau says:

    Thanks for sharing your thoughts on noticias sociales.
    Regards

  5. Food & Drink says:

    This is a really good tip especially to those fresh to the blogosphere.

    Short but very precise info… Thank you for sharing this one.
    A must read article!

  6. Excellent beat ! I wish to apprentice at the same time as you amend your site,
    how can i subscribe for a blog site? The account aided me a
    appropriate deal. I had been tiny bit acquainted of this your broadcast provided shiny clear concept

  7. I feel this is among the most vital info for me. And i am
    glad reading your article. But should statement on few basic things, The site style is ideal, the articles is really nice :
    D. Just right job, cheers

Skip to main content