Skip to content

Passing arguments with the Start-Process cmdlet #18906

Description

@lclutz

Prerequisites

Steps to reproduce

I am experiencing issues running external programs with the Start-Process cmdlet.

For example I think the following two commands should produce the same output but they do not:

PS> pwsh -Command 'Write-Host "`"Hello World!`""'
"Hello World!"
PS> Start-Process -FilePath 'pwsh' -ArgumentList @('-Command', 'Write-Host "`"Hello World!`""') -Wait -NoNewWindow
Hello World!`

There seems to be an issue with how parameters in the ArgumentList are passed to the external program.

Expected behavior

PS> Start-Process -FilePath 'pwsh' -ArgumentList @('-Command', 'Write-Host "`"Hello World!`""') -Wait -NoNewWindow
"Hello World!"

Actual behavior

PS> Start-Process -FilePath 'pwsh' -ArgumentList @('-Command', 'Write-Host "`"Hello World!`""') -Wait -NoNewWindow
Hello World!`

Error details

No response

Environment data

PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.1
PSEdition                      Core
GitCommitId                    7.3.1
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions