[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SQL Instances Script

Posted on 2013-12-18
4
Medium Priority
?
479 Views
Last Modified: 2013-12-19
Please provide a vbscript to find SQL instances of remote machine.
0
Comment
Question by:Prasadkosana
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 2000 total points
ID: 39728751
Hi,
here a sample script:
' Please adjust to your server name
strServerName = "RAINERJDEV"

' Default variables
defaultInstanceName = "MSSQLSERVER"
strMsg = "Installed instances on " & strServerName & ":" & vbcrlf
Const HKEY_LOCAL_MACHINE = &H80000002

' Now start by reading reg key
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strServerName & "\root\default:StdRegProv")
strMSSQLRootKeyPath = "SOFTWARE\Microsoft\Microsoft SQL Server"
strInstanceKey = "InstalledInstances"
objRegistry.GetMultiStringValue HKEY_LOCAL_MACHINE, strMSSQLRootKeyPath, strInstanceKey,arrOfInstances
If IsNull(arrOfInstances) = false Then 
	' We have a SQL Server
	For Each strRegValue In arrOfInstances
		If UCase(strRegValue) <> defaultInstanceName Then 
			strSQLInstanceName = strServerName & "\" & strRegValue
		Else
			strSQLInstanceName = strServerName
		End If
		strMsg = strMsg & strSQLInstanceName & vbcrlf
	Next
Else
	strMsg = strMsg & "No SQL Server installed!"
End If
Set objRegistry = Nothing
Msgbox strMsg

Open in new window


Displays all instances (or if default instance the machine name) on that machine.
You just have to ensure that you have proper permissions to access and read the remote registry.

HTH
Rainer
0
 
LVL 10

Expert Comment

by:Ramesh Babu Vavilla
ID: 39728902
open command prompt and then
osql -L

or SQLCMD -L
0
 

Author Comment

by:Prasadkosana
ID: 39730016
Hi,

  Can you also help me to integrate the above vbscript in system cneter orchetsrator?

Thanks,
Prasad.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question