Closed magicmarkh-zz closed 4 years ago
Hi @magicmarkh ,
I cannot reproduce; inside a script.ps1
i have:
Function Test-Function{
Write-Output "Inside Function"
Close-PASSession
exit
}
Write-Output "Testing Something"
Test-Function
Write-Output "Something"
When .\script.ps1
is executed, the output is:
PS > .\script.ps1
Testing Something
Inside Function
To confirm if this is an issue with Close-PASSession
or not, you could substitute it's invocation with another function, Get-Process
perhaps:
Function Test-Function{
Write-Output "Inside Function"
get-process powershell
exit
}
Write-Output "Testing Something"
Test-Function
Write-Output "Something"
PS>.\script.ps1
Testing Something
Inside Function
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
------- ------ ----- ----- ------ -- -- -----------
766 35 93652 111740 1.86 12212 3 powershell
Pspete,
thanks for looking into this so quickly. For the test, on your inside function, it would need to be setup as follows:
Function Test-Function{
Close-PASSession
Write-Output "Inside Function" exit
}
I suspect you'll see the behavior once you switch the write-output & close-passession
On Tue, May 5, 2020 at 9:52 AM Pete Maan notifications@github.com wrote:
Hi @magicmarkh https://github.com/magicmarkh ,
I cannot reproduce; inside a script.ps1 i have:
Function Test-Function{
Write-Output "Inside Function" Close-PASSession exit
} Write-Output "Testing Something"Test-FunctionWrite-Output "Something"
When .\script.ps1 is executed, the output is:
PS > .\script.ps1 Testing Something Inside Function
To confirm if this is an issue with Close-PASSession or not, you could substitute it's invocation with another function, Get-Process perhaps:
Function Test-Function{
Write-Output "Inside Function" get-process powershell exit
} Write-Output "Testing Something"Test-FunctionWrite-Output "Something"
PS>.\script.ps1 Testing Something Inside Function
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName------- ------ ----- ----- ------ -- -- ----------- 766 35 93652 111740 1.86 12212 3 powershell
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pspete/psPAS/issues/265#issuecomment-624102602, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIBLSNH54R3YOZCCEGJYYRTRQARZLANCNFSM4MZDDY3A .
--
-Mark
Afraid not
Function Test-Function{
Close-PASSession -verbose
Write-Output "Inside Function"
exit
}
Write-Output "Testing Something"
Test-Function
Write-Output "Something"
Results in:
PS> \script.ps1
Testing Something
VERBOSE: POST https://xxxxxxx/PasswordVault/API/Auth/Logoff with 0-byte payload
VERBOSE: received 16-byte response of content type application/json; charset=utf-8
Inside Function
I'll test more. thanks Pete.
On Tue, May 5, 2020 at 10:43 AM Pete Maan notifications@github.com wrote:
Afraid not
Function Test-Function{
Close-PASSession -verbose Write-Output "Inside Function" exit
} Write-Output "Testing Something"Test-FunctionWrite-Output "Something"
Results in:
PS> \script.ps1
Testing Something VERBOSE: POST https://xxxxxxx/PasswordVault/API/Auth/Logoff with 0-byte payload VERBOSE: received 16-byte response of content type application/json; charset=utf-8 Inside Function
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pspete/psPAS/issues/265#issuecomment-624133331, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIBLSNDVSJJC7ITTQMPPGQLRQAX2VANCNFSM4MZDDY3A .
--
-Mark
Bad case. My apologies. The issue is that I'm trying to run Close-PASSession when there is no active session, which causes the failure.
Perhaps Close-PASSession -ErrorAction SilentlyContinue
may be an option in your function?
unfortunately not. I just added a boolean value to the function and run a quick if. thanks Pete!
On Mon, May 11, 2020 at 11:12 AM Pete Maan notifications@github.com wrote:
Perhaps Close-PASSession -ErrorAction SilentlyContinue may be an option in your function?
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/pspete/psPAS/issues/265#issuecomment-626800596, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIBLSNBO3EIOSCYEK4OUETDRRAPVNANCNFSM4MZDDY3A .
--
-Mark
Describe the issue I have a script that calls a function whenever an error occurs, and if the script passes $true to the function, it's supposed to exit the script and no longer execute. However, the break in the Close-PASSession module causes my function to exit, allowing the script to continue while everything else will fail.
To Reproduce Steps to reproduce the behavior:
Expected behavior script exits before write-host runs.
Screenshots & Console Output If applicable, add screenshots to help explain your problem.
Console Output Code Block:
Your Environment Include relevant details about your environment
Additional context Add any other context about the problem here.