0

I have been working to automate my SQL patching. I have found that I can run the command below from my central server and it will perform the upgrade on the remote computer. My issue is that I can only run one command at a time until the command comes back with a response. I am trying to figure out how I can run this command against 100 different computers at one time and all the upgrades can be performed at once in parallel and not one by one.

Invoke-Command -computername SQLServer1 -command {D:\DBA\SQLPatching\SQL_2014\SP1\Patch-SQL2014_SP1.bat}

I would just be replacing the -computername parameter with my list of servers being patched.

Does anyone have any suggestions?

Garry B
  • 211
  • 1
  • 3
  • 14
  • 1
    See: http://stackoverflow.com/questions/4016451/can-powershell-run-commands-in-parallel – Kev Sep 11 '15 at 17:11
  • 2
    Adn without jobs: http://serverfault.com/questions/626711/how-do-i-run-my-powershell-scripts-in-parallel-without-using-jobs – Kev Sep 11 '15 at 17:11

1 Answers1

0
Invoke-Command -ComputerName $computers -ScriptBlock {D:\DBA\SQLPatching\SQL_2014\SP1\Patch-SQL2014_SP1.bat }

Assuming that bat file is in D on all the computers. Using invoke-command will run in parallel if you have a list of machines to pass to if.

If you instead used a ForEach $computer in $computers you would have it run one at a time.