intellij-powershell icon indicating copy to clipboard operation
intellij-powershell copied to clipboard

Powershell script hangs when started from Run Configuration with missing mandatory parameter.

Open Dimi1010 opened this issue 4 years ago • 0 comments

The current PowerShell scripts when ran with the default run configuration will run in interactive mode.

In interactive mode, PowerShell upon encountering a missing mandatory parameter, will prompt the user to input that parameter, which the run window does not support at the moment, and this causes the process hanging that can only be resolved by terminating it.

A potential fix is to run PowerShell in non-interactive mode, when starting from a run configuration, by adding "-NonInteractive" to the command parameters, as that would cause the script to terminate with missing mandatory parameter exception instead.

It would be nice if the "-NonInteractive" parameter be added to the default PowerShell run configuration template of the plugin.

Tested on Pycharm 2021.2.1

Reproducable code:

MandatoryParamDeadlock.ps1

param(
    # Mandatory Demo Parameter
    [Parameter(Mandatory)]
    [string]
    $DemoMandatoryParameter
)

Write-Host $DemoMandatoryParameter

Hanging Run Configuration: image

Fixed Run Configuration: image

Dimi1010 avatar Aug 01 '21 12:08 Dimi1010