Powershell ThrottleLimit limit

SKG 66 Reputation points
2021-08-22T20:54:54.78+00:00

Hi All,

I am using Powershell 7.1.4

I have following script. My goal is to execute 10 calls to a SP in parallel. But i am observing at a given time only 5 calls are being made to sql server

any ideas

1..10 | ForEach-Object -Parallel {
$ServerName = "mssql"
$DatabaseName = "testdb"
$Password = "Password!"
$UserId="sa"

    $query="exec [Test].[spPopulateTestTable] @SWID =519692, @MaxThreads =5, @CurrentThreadId =$_"
    Invoke-Sqlcmd -Server $ServerName -Database $DatabaseName -Password $Password -User $userid -Query $query
    Write-output "Completed $Thread"

} -ThrottleLimit 10

TIA

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,462 questions
0 comments No comments
{count} votes