private/Cleanup-Environment.ps1
function Cleanup-Environment { Param( [int]$exitCode = 0 ) Get-PSSession | Where-Object { $_.Name -match "-nimbus$" } | Remove-PSSession if ( $env:localTesting ) { Break script # a bit of a hack, but should work } elseif ( $exitCode -ne 0 ) { throw } else { Write-Output "Run was successful." } } |