Miroslav Vanický
Miroslav Vanický

Reputation: 19

Running pwsh.exe with -File never returns

I created simple Test.ps1 script like this:

echo $org = Get-VBOOrganization -Name "OrgName.onmicrosoft.com" >> Test.ps1
echo $org.Id.ToString() >> Test.ps1

Then I run this script with pwsh:

pwsh -File Test.ps1

Script executes, writes output (some guid), but then it never returns back to cmdline

Important note: When I use powershell.exe instead of pwsh.exe then I am correctly returned to cmdline. So this works:

powershell -File Test.ps1

But, I need to use pwsh to use PS7.

I tried to play with -MTA & -NonInteractive parameters, nothing helped. Would anyone know what else to try?

Thanks a lot!

Upvotes: 0

Views: 25

Answers (1)

Miroslav Vanický
Miroslav Vanický

Reputation: 19

Problem solved by calling Exit in the end of the script:

[System.Environment]::Exit(0)

Upvotes: 0

Related Questions