SymptomsWhen you use prlctl exec command to run powershell commands inside a VE, the session is not closed automatically.
# prlctl exec VE_NAME powershell Set-ExecutionPolicy Unrestricted
When issuing the above command one has to press CRTL+C to exit out of the powershell session. However, when running this same command from the command prompt directly in the guest environment, powershell exits as soon as the command finishes executing.
CauseThere is no clear proof, but it looks like there is a bug in powershell itself. It erroneously wants to read from stdin even when run non-interactively.
WorkaroundYou can input NUL to the script or command using cmd.exe.
Run a command:
prlctl exec VE_NAME 'cmd /c powershell.exe -Command dir variable: >> c:\\command\\input.out < NUL'
Run a script:
prlctl exec VE_NAME 'cmd /c powershell.exe -File c:\\command\\input.ps1 < NUL'
Note: Do not forget to replace VE_NAME with the actual virtual machine name.