SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

Powershell script to allow you to login to any instance or sqlserver

By terryj30, 2008/10/21

Total article views: 1302 | Views in the last 30 days: 108

This Powershell script well allow you to search for any instance or sql server you have or have enterned in to the file. once you run this powershell script it will ask you for a string type in what ever instance you want it mssql then it will give you a number of instances you can then press 1 to what ever number the server is on and it will log you in.

PS C:\CheckSQLServer\sql> ./loginsql.ps1
search string: IBTKYPSP32
Press 1 for : IBTKYPSP32A006
Press 2 for : IBTKYPSP32A017
Press 3 for : IBTKYPSP32A021
Press 4 for : IBTKYPSP32A026
Press 5 for : IBTKYPSP32A028
Press 6 for : IBTKYPSP32A031
Press 7 for : IBTKYPSP32A100
Press 8 for : IBTKYPSP32B017
Press 9 for : IBTKYPSP32B026
Press 10 for : IBTKYPSP32B031
Press 11 for : IBTKYPSP32A034
Press 12 for : IBTKYPSP32B034\HOSTED_P1
Press 13 for : IBTKYPSP32A036\HOSTED_P1
Press 14 for : IBTKYPSP32B037\HOSTED_P1
Enter choice : 1 - 14: 14
Logging on to the SQLSERVER you requested: IBTKYPSP32B037\HOSTED_P1
IBTKYPSP32B037\HOSTED_P1
1> sp_who
2> go
spid ecid status loginame
hostname
cmd requ
------ ------ ------------------------------ --------------------------------------------------------------------------------------------
------------ ----------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------- ---------------- ----
1 0 background sa

RESOURCE MONITOR
2 0 background sa

RESOURCE MONITOR
3 0 background sa

RESOURCE MONITOR
4 0 background sa

RESOURCE MONITOR
5 0 background sa

 

By terryj30, 2008/10/21

Total article views: 1302 | Views in the last 30 days: 108
Your response
 
 
Related tags

powershell    
 
 
Contribute
Like this? Try these...

Delete Duplicate values

By SQL Species | Category: T-SQL
| 1,401 reads

Free registration required...

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Login (existing users)

Login

Email:   Password:   Remember me: Forgotten your password?

Register (new users)

Register

Email:   Password:
Confirm:

Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

Steve Jones
Editor, SQLServerCentral.com