My typical experience with PowerShell is I can copy/paste multiple lines of commands to execute, and PowerShell executes them in sequence without interruption.
For example, I can copy these 5 lines and paste them in PowerShell:
Write-Host "=== START TEST ==="
cmd.exe
ping localhost -n 1
exit
Write-Host "=== END TEST ==="
And PowerShell will dutifully execute each command at each prompt:

But I've recently encountered some environments where execution "halts" after cmd.exe, and only continues once I've manually exited the command prompt:

Is this a behavior I have control over? How to I make the second environment behave like the first one?
NOTE: I know there's other ways to make my example work without copy/pasting the commands as I've shown. I'm not interested in alternatives to this specific use case. I am interested in achieving consistent behavior when copy/pasting commands like this in various PowerShell environments.
Thank you!
P.S.
Regarding my test environments:
- Example 1 was done using PowerShell 5.1.14409.1005 on Windows Server 2012 R2
- Example 2 was done using PowerShell 5.1.17763.4720 on Windows Server 2019