Skip to content

Entering a string for a switch parameter causes powershell to crash #1450

Closed
@andy2002a

Description

@andy2002a

System Details

  • Operating system name and version:
  • VS Code version:
  • PowerShell extension version: 1.8.1
  • Output from $PSVersionTable:

Name Value


PSVersion 5.1.14393.2312
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.2312
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Copy / paste the following commands into the PowerShell Integrated Console, and paste the output here:

code -v
1.25.1
1dfc5e557209371715f655691b1235b6b26a06be
x64

$pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      8      1      0

code --list-extensions --show-versions
joshbax.mdhelper@0.0.11
ms-vscode.PowerShell@1.8.1

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14393.2312
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.2312
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

Steps to Reproduce:

1.Run the command block below
2.Enter random text when prompted in the console
3.You get an error saying that powershell crashed

If you launch the same code in the ISE you will get an error in the console saying that the switch param will not accept a string. However, the shell will not crash.

[cmdletbinding()]
param(
    [Parameter(Mandatory = $true, HelpMessage = 'test')]
    [Switch]$ServerName,

    [Parameter(Mandatory = $true, HelpMessage = 'test')]
    [Switch]$Server2Name

)#End cmdletbinding

Attached Logs

Sent to vscode-powershell@microsoft.com

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions