You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to execute a .ps1 script under PowerShell Core 6.1 (CentOS Linux 7) using the Unix method of specifying '/usr/bin/pwsh' in the script's 'shebang' line like this:
When I try to invoke the above script from the Linux shell command line, pwsh reports the below error:
The argument '-NoLogo -NoProfile' is not recognized as the name of a script file. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
It appears that the call to 'pwsh' along with its command arguments is being misinterpreted here and that might be leading to the error.
Question: Other than invoking the script using 'pwsh -NoLogo -NoProfile -f myscript.ps1' approach (which works fine), is there some way we could specify the command arguments to pwsh within the script itself (perhaps using escape characters in some manner)?
Environment data
Name Value
---- -----
PSVersion 6.1.0
PSEdition Core
GitCommitId 6.1.0
OS Linux 3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14 21:49:04 UTC 2018
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
The text was updated successfully, but these errors were encountered:
I am trying to execute a .ps1 script under PowerShell Core 6.1 (CentOS Linux 7) using the Unix method of specifying '/usr/bin/pwsh' in the script's 'shebang' line like this:
myscript.ps1:
When I try to invoke the above script from the Linux shell command line, pwsh reports the below error:
It appears that the call to 'pwsh' along with its command arguments is being misinterpreted here and that might be leading to the error.
Question: Other than invoking the script using 'pwsh -NoLogo -NoProfile -f myscript.ps1' approach (which works fine), is there some way we could specify the command arguments to pwsh within the script itself (perhaps using escape characters in some manner)?
Environment data
The text was updated successfully, but these errors were encountered: