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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.