PowerShell Tool Time: Our First Toolbox

  • Comments posted to this topic are about the item PowerShell Tool Time: Our First Toolbox

  • Thanks for the continuing lessons.

  • 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?

    412-977-3526 call/text

  • 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, Pluralsight courses

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

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply