Skip to content

Commit ecfd694

Browse files
committed
1 parent 930a120 commit ecfd694

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

AutomatedLab/AutomatedLab.psm1

+4-3
Original file line numberDiff line numberDiff line change
@@ -2903,12 +2903,13 @@ function New-LabPSSession
29032903
}
29042904
elseif ($internalSession.Count -ne 0)
29052905
{
2906-
$sessionsToRemove = $internalSession | Select-Object -Skip $(Get-LabConfigurationItem -Name MaxPSSessionsPerVM)
2906+
$sessionsToRemove = $internalSession | Select-Object -Skip (Get-LabConfigurationItem -Name MaxPSSessionsPerVM)
29072907
Write-PSFMessage "Found orphaned sessions. Removing $($sessionsToRemove.Count) sessions: $($sessionsToRemove.Name -join ', ')"
29082908
$sessionsToRemove | Remove-PSSession
29092909

29102910
Write-PSFMessage "Session $($internalSession[0].Name) is available and will be reused"
2911-
$sessions += $internalSession | Where-Object State -eq 'Opened' | Select-Object -First 1
2911+
#Replaced Select-Object with array indexing because of https://github.com/PowerShell/PowerShell/issues/9185
2912+
($sessions += $internalSession | Where-Object State -eq 'Opened')[0] #| Select-Object -First 1
29122913
}
29132914
}
29142915

@@ -3228,7 +3229,7 @@ function Invoke-LabCommand
32283229
#required to suppress verbose messages, warnings and errors
32293230
Get-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState
32303231

3231-
if (-not (Get-LabVm -IncludeLinux))
3232+
if (-not (Get-LabVM -IncludeLinux))
32323233
{
32333234
Write-LogFunctionExitWithError -Message 'No machine definitions imported, so there is nothing to do. Please use Import-Lab first'
32343235
return

AutomatedLabWorker/AutomatedLabWorker.psm1

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ function Invoke-LWCommand
222222

223223
if ($AsJob)
224224
{
225-
$job = Invoke-Command @parameters -ErrorAction SilentlyContinue -ErrorVariable invokeError
225+
$job = Invoke-Command @parameters -ErrorAction SilentlyContinue
226226
}
227227
else
228228
{

PSLog/PSLog.psm1

+2-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ function Write-ScreenInfo
494494

495495
$newSize = ($Global:taskStart).Length - 1
496496
if ($newSize -lt 0) { $newSize = 0 }
497-
$Global:taskStart = $Global:taskStart | Select-Object -first (($Global:taskStart).Length - 1)
497+
#Replaced Select-Object with array indexing because of https://github.com/PowerShell/PowerShell/issues/9185
498+
$Global:taskStart = $Global:taskStart[0..(($Global:taskStart).Length - 1)] #$Global:taskStart | Select-Object -First (($Global:taskStart).Length - 1)
498499
}
499500

500501

0 commit comments

Comments
 (0)