PowerShell Tool Time: Our First Toolbox

  • Mike Fal

    SSC Veteran

    Points: 265

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

  • akljfhnlaflkj

    SSC Guru

    Points: 76202

    Thanks for the continuing lessons.

  • Robert Sterbal

    SSChampion

    Points: 10967

    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

  • g.britton

    SSChampion

    Points: 13686

    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[/url]

  • Geoff A

    SSChampion

    Points: 11407

    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 5 (of 5 total)

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