SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


PowerShell Tool Time: Our First Toolbox


PowerShell Tool Time: Our First Toolbox

Author
Message
sake.god
sake.god
SSC Veteran
SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)

Group: General Forum Members
Points: 203 Visits: 170
Comments posted to this topic are about the item PowerShell Tool Time: Our First Toolbox
Iwas Bornready
Iwas Bornready
SSC Guru
SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)

Group: General Forum Members
Points: 64446 Visits: 886
Thanks for the continuing lessons.
robert.sterbal 56890
robert.sterbal 56890
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8832 Visits: 1647
Conceptually does it make sense to do this against hundreds of servers, or should I just stay focused on more standard deployments on my own box at first?
Gerald Britton
Gerald Britton
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11824 Visits: 1800
You just made me wish all over again that MS had gone with Python. The code is so much more readable:

import pyodbc

def Test_SQLConnection(Instances):
ret = []
for Instance in Instances:
try:
conn = pyodbc.connect('DRIVER={SQL Native Client};SERVER=' + Instance + ';Trusted_Connection=yes;')
curs = conn.cursor()
curs.execute("SELECT @@SERVERNAME as Name,Create_Date FROM sys.databases WHERE name = 'TempDB'")
for row in curs:
ret.append((row.Name, row.Create_Date))
except:
pass
return ret



No braces (except for the connection string, of course); no $-signs

Gerald Britton, MCSE-DP, MVPToronto PASS Chapter
Geoff A
Geoff A
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10201 Visits: 1844
robert.sterbal 56890 - Wednesday, October 28, 2015 7:10 AM
Conceptually does it make sense to do this against hundreds of servers, or should I just stay focused on more standard deployments on my own box at first?

are you asking about storing scripts on the C: drive across hundreds of servers or running the function Test-SQLConnection across hundreds of servers?

i can't speak to the C: drive bit as i have implemented VSTS so I can version my code with an online repo as a backup.

VisualStudiowithPowerShell

as far as running the function Test-SQLConnection across hundreds of servers, i can say from experience it will work but it will take forever. consider using a modulo to break up the work across multiple threads.

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search