Multithread : Powershell - To execute .sql procedures in multiple servers

  • Hi Experts

    Does anyone any implemented any such logic wherein it helps life in deploying multiple scripts in different servers in parallel using multi-thread?

    Thanks

    Thanks.

  • deploying multiple scripts in different servers in parallel using multi-thread?

    In PowerShell 3.0 you can utilize PowerShell workflows to run multiple task "in the background" to execute and run. I would not really regard this as a multi-thread action in the sense of CPU threads, it more creates multiple namespaces that your task runs in.

    As far as logic goes there are a few articles online that can give you a quick intro to how you might set this up here and here.

    The first link goes over use of the Workflow keywords that came in 3.0 and creating a workflow object to run your command in parallel. I think a more simple method would be to just utilize the "Start-Job" cmdlet, but it would be based on how many servers and the complexity of the script you are running against each. Just off the top of my head I would say it would not be to complicated to just do the following:

    1) Build your task to run on each server

    2) Get total count of servers to run against, so you can create batches

    3) Create a set of background jobs (maybe in batches of 5 or 10) that is basically a connection to each server

    4) Then you would decide if you want to wait until that batch is completed before going to the next 5 or 10, or as one is finished start another job

    5) In the logic you would just check the status of each job to know when it is completed or erred to log the information.

    Shawn Melton
    Twitter: @wsmelton
    Blog: wsmelton.github.com
    Github: wsmelton

Viewing 3 posts - 1 through 2 (of 2 total)

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