From b64ad9f5fbe6fa85f860311f81ec0d6392d5fc01 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 26 Jul 2017 12:21:30 -0700 Subject: [PATCH] Added Current Host to Threads This allows passing open connections through to the threads. For example: without this additional code running Get-AzureRMVM would require running Login-AzureRMAccount on each thread. With the addition of this code you only need to run Login-AzureRMAccount outside the scope of the Start-RSJob cmdlet one time and not in each thread. --- PoshRSJob/Public/Start-RSJob.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PoshRSJob/Public/Start-RSJob.ps1 b/PoshRSJob/Public/Start-RSJob.ps1 index 9775ac5..2b9011a 100644 --- a/PoshRSJob/Public/Start-RSJob.ps1 +++ b/PoshRSJob/Public/Start-RSJob.ps1 @@ -413,7 +413,7 @@ Function Start-RSJob { Else { Write-Verbose "Creating new runspacepool <$Batch>" $RunspacePoolID = $Batch - $RunspacePool = [runspacefactory]::CreateRunspacePool($InitialSessionState) + $RunspacePool = [runspacefactory]::CreateRunspacePool(1, $Throttle, $InitialSessionState, $Host) If ($RunspacePool.psobject.Properties["ApartmentState"]) { #ApartmentState doesn't exist in Nano Server $RunspacePool.ApartmentState = 'STA'