Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

List SQL Server Instances with Powershell remote registry search

26 June,2012 by Tom Collins

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: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

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

Working...
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.

Working...

Post a comment on List SQL Server Instances with Powershell remote registry search


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer