diff --git a/PSKoans/Private/Invoke-Koan.ps1 b/PSKoans/Private/Invoke-Koan.ps1 index fe5f0399..560c0b5c 100644 --- a/PSKoans/Private/Invoke-Koan.ps1 +++ b/PSKoans/Private/Invoke-Koan.ps1 @@ -61,7 +61,8 @@ } } - $ps = [powershell]::Create($script:KoanRunspace) + $ps = [powershell]::Create() + $ps.Runspace = $script:KoanRunspace $ps.AddScript($Script, <# useLocalScope: #> $true) > $null $ps.AddParameter('Params', $ParameterSplat) > $null diff --git a/PSKoans/Private/New-KoanRunspace.ps1 b/PSKoans/Private/New-KoanRunspace.ps1 index b39beda9..d564fd44 100644 --- a/PSKoans/Private/New-KoanRunspace.ps1 +++ b/PSKoans/Private/New-KoanRunspace.ps1 @@ -22,7 +22,8 @@ function New-KoanRunspace { $runspace = [runspacefactory]::CreateRunspace() $runspace.Open() $runspace.Name = 'PSKoans.KoanRunspace' - $ps = [powershell]::Create($runspace) + $ps = [powershell]::Create() + $ps.Runspace = $runspace try { $script = { diff --git a/tests/Functions/Private/New-KoanRunspace.Tests.ps1 b/tests/Functions/Private/New-KoanRunspace.Tests.ps1 index a1e378ef..b1cc8101 100644 --- a/tests/Functions/Private/New-KoanRunspace.Tests.ps1 +++ b/tests/Functions/Private/New-KoanRunspace.Tests.ps1 @@ -44,7 +44,8 @@ Describe 'New-KoanRunspace' { It 'preloads the runspace with PSKoans' { $runspace = InModuleScope 'PSKoans' { New-KoanRunspace } - $ps = [powershell]::Create($runspace) + $ps = [powershell]::Create() + $ps.Runspace = $runspace try { $ps.AddCommand('Get-Module').AddParameter('Name', 'PSKoans') > $null