I have the same problem: a script that stops running in the PowerShell ISE whenever a warning is issued, even a simple one.
#if __cplusplus < 201703L
#warning "This build does not have access to >= c++17 features."
#endif
Result of the script in the PowerShell ISE:
Compiling .pio\build\STM32F103RC_creality\src\src\lcd\e3v2\proui\dwinui.cpp.o
platformio.exe : Marlin\src\inc\Warnings.cpp:35:4: warning: #warning "This build does not have access to >= c++17 features." [-Wcpp]
En W:\3DPrinter\Marlin_bugfix-2.1.x_test\Compile.ps1: 36 Carácter: 3
+ . $env:USERPROFILE\.platformio\penv\Scripts\platformio.exe run -e $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Marlin\src\inc\...tures." [-Wcpp]:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
And the execution is aborted.
Result of script in a Powershell Terminal:
Compiling .pio\build\STM32F103RC_creality\src\src\lcd\e3v2\proui\dwinui.cpp.o
Marlin\src\inc\Warnings.cpp:35:4: warning: #warning "This build does not have access to >= c++17 features." [-Wcpp]
35 | #warning "This build does not have access to >= c++17 features."
| ^~~~~~~
Compiling .pio\build\STM32F103RC_creality\src\src\lcd\e3v2\proui\endstop_diag.cpp.o
And the script finished normally.
So, there is a difference when the script is executed in the PowerShell ISE.