Jobs in PoSh to Create a Load

I saw this from Argenis Fernandez, and thought it was wonderful.

1..128 | % { start-job -name ‘job name’ -scriptblock { & sqlcmd -S instanceName -U sa -P ‘iLovePoSh’ -i /home/username/test.sql } }

Create 128 threads, each running a background job in PowerShell to connect to an instance and run a script file.

Start-Job is used to begin a job, and then you can get information from Get-Job and use Stop-Job to turn things off.

Very cool. Looking forward to trying to use this in a demo and make things happen.

About way0utwest

Editor, SQLServerCentral
This entry was posted in Blog and tagged , . Bookmark the permalink.