List SQL Server Instances with Powershell remote registry search

26 June,2012 by Jack Vamvas

Question : I want to list the SQL Server Instances on a remote server. How can I do this with a Powershell script?

I've alread read List SQL Server Instances using Powershell and Get-ItemProperty   for local registry search

Answer:  Remote registry access  with Powershell is about using  a) the [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey Object b) the OpenRemoteBaseKey Method  c) the GetValueNames method d) the OpenSubKey method

This is a simple example


 $server = "myServer"
 $keypath = 'Software\Microsoft\Microsoft SQL Server\Instance Names\SQL'
 $roottype = "LocalMachine"
 $rootkey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($roottype,$server)

 $rootkey = $rootkey.OpenSubKey($keypath )
 Foreach($instance in $rootkey.GetValueNames()){$instance}

 Related Posts

List SQL Server Instances using Powershell and Get-ItemProperty

SQL Server – Send email using Powershell

SQL Server Version with Powershell

Author: Jack Vamvas (


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer