# Help: pwsh command won't take command-line arguments

**URL:** <https://forums.powershell.org/t/help-pwsh-command-wont-take-command-line-arguments/13673>\
**Category:** PowerShell Help\
**Created:** [January 17, 2020, 5:31pm UTC](https://forums.powershell.org/t/help-pwsh-command-wont-take-command-line-arguments/13673 "2020-01-17T17:31:10Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![nebosite](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@nebosite](https://forums.powershell.org/u/nebosite)\
**Post date:** [January 17, 2020, 5:31pm UTC](https://forums.powershell.org/t/help-pwsh-command-wont-take-command-line-arguments/13673/1 "2020-01-17T17:31:10Z")

</div>

_([cross posted on stack overflow](https://stackoverflow.com/questions/59792833/powershell-pwsh-does-not-take-command-line-arguments/59793074#59793074))_

According to [pwsh documentation](https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Core/About/about_pwsh?view=powershell-7), I should be able to pass command-line arguments but I am getting errors instead (both from a PS prompt and from a CMD prompt):

```auto
> pwsh -NoExit
-NoExit : The term '-NoExit' is not recognized as the name of a cmdlet, function, script file, or operable program.
...

> pwsh -NoLogo
-NoLogo : The term '-NoLogo' is not recognized as the name of a cmdlet, function, script file, or operable program.
...

> pwsh -h
-h : The term '-h' is not recognized as the name of a cmdlet, function, script file, or operable program.
...

> pwsh -Command "Write-host hello"
-Command : The term '-Command' is not recognized as the name of a cmdlet, function, script file, or operable program.
...

```

But this works:

```auto
> pwsh "Write-host hello"
hello

```

My pwsh version is 6.2.3.0

What is going on???

&nbsp;

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [January 17, 2020, 9:17pm UTC](https://forums.powershell.org/t/help-pwsh-command-wont-take-command-line-arguments/13673/2 "2020-01-17T21:17:22Z")

</div>

Did you try to run the pwsh executable with its complete path?

---

<div class="post-metadata">

**Author:** ![kpatnayakuni](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/kpatnayakuni/32/19_2.png) [@kpatnayakuni](https://forums.powershell.org/u/kpatnayakuni)\
**Post date:** [January 18, 2020, 5:23am UTC](https://forums.powershell.org/t/help-pwsh-command-wont-take-command-line-arguments/13673/3 "2020-01-18T05:23:15Z")

</div>

Yes, it looks like your installation is broken, please reinstall and check to see if it’s working.

Also, try using ‘/’ instead of ‘-’

[pre]\> pwsh /nologo[/pre]

Thank you.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [January 18, 2020, 7:47am UTC](https://forums.powershell.org/t/help-pwsh-command-wont-take-command-line-arguments/13673/4 "2020-01-18T07:47:40Z")

</div>

> [@](#):
>
> Also, try using ‘/’ instead of ‘-’

Why that? What difference would it make if the executable in front of the argument isn’t found?

---

<div class="post-metadata">

**Author:** ![kpatnayakuni](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/kpatnayakuni/32/19_2.png) [@kpatnayakuni](https://forums.powershell.org/u/kpatnayakuni)\
**Post date:** [January 18, 2020, 8:04am UTC](https://forums.powershell.org/t/help-pwsh-command-wont-take-command-line-arguments/13673/5 "2020-01-18T08:04:12Z")

</div>

> [@](#):
>
> > [Kiran wrote:](https://powershell.org/forums/topic/help-pwsh-command-wont-take-command-line-arguments/#post-198722)
> > Also, try using '/' instead of '-'
> 
> Why that? What difference would it make if the executable in front of the argument isn't found?

Yeah I know, you are right, but just in case, that’s it.

---

<div class="post-metadata">

**Author:** ![js2010](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@js2010](https://forums.powershell.org/u/js2010)\
**Post date:** [January 18, 2020, 10:20am UTC](https://forums.powershell.org/t/help-pwsh-command-wont-take-command-line-arguments/13673/6 "2020-01-18T10:20:43Z")

</div>

Are you running the executable or a .bat file?

---

<div class="post-metadata">

**Author:** ![kvprasoon](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/kvprasoon/32/4449_2.png) [@kvprasoon](https://forums.powershell.org/u/kvprasoon)\
**Post date:** [January 19, 2020, 5:21am UTC](https://forums.powershell.org/t/help-pwsh-command-wont-take-command-line-arguments/13673/7 "2020-01-19T05:21:07Z")

</div>

what is it showing when you do ?

```
pwsh --help
pwsh /?
```

It should give the possible options to use with it.

---

<div class="post-metadata">

**Author:** ![nebosite](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@nebosite](https://forums.powershell.org/u/nebosite)\
**Post date:** [January 22, 2020, 3:19pm UTC](https://forums.powershell.org/t/help-pwsh-command-wont-take-command-line-arguments/13673/8 "2020-01-22T15:19:10Z")

</div>

Nope:

```
PS> C:\Users\ericj\.dotnet\tools\pwsh.exe --help
At line:1 char:3
+ --help
...
Unexpected token 'help' in expression or statement.

PS> C:\Users\ericj\.dotnet\tools\pwsh.exe /?
/? : The term '/?' is not recognized as the name of a cmdlet, function, script file, or operable program.

PS> C:\Users\ericj\.dotnet\tools\pwsh.exe "write-host hello"
hello
```

---

<div class="post-metadata">

**Author:** ![nebosite](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@nebosite](https://forums.powershell.org/u/nebosite)\
**Post date:** [January 22, 2020, 3:25pm UTC](https://forums.powershell.org/t/help-pwsh-command-wont-take-command-line-arguments/13673/9 "2020-01-22T15:25:19Z")

</div>

Uninstalling and reinstalling did not work:

```
PS> dotnet tool uninstall --global PowerShell
Tool 'powershell' (version '6.2.3') was successfully uninstalled.
PS> pwsh
pwsh : The term 'pwsh' is not recognized as the name of a cmdlet, function, script file, or operable program.

PS> get-command pwsh
get-command : The term 'pwsh' is not recognized as the name of a cmdlet, function, script file, or operable program.

PS> dotnet tool install --global PowerShell
You can invoke the tool using the following command: pwsh
Tool 'powershell' (version '6.2.3') was successfully installed.

PS> get-command pwsh
CommandType Name Version Source
----------- ---- ------- ------
Application pwsh.exe 6.2.3.0 C:\Users\ericj\.dotnet\tools\pwsh.exe

PS> pwsh /nologo
/nologo : The term '/nologo' is not recognized as the name of a cmdlet, function, script file, or operable program.

PS> pwsh /?
/? : The term '/?' is not recognized as the name of a cmdlet, function, script file, or operable program.

PS> pwsh --help
Missing expression after unary operator '--'.
Unexpected token 'help' in expression or statement.

PS> pwsh "write-host hello"
hello
```

---

<div class="post-metadata">

**Author:** ![js2010](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@js2010](https://forums.powershell.org/u/js2010)\
**Post date:** [January 22, 2020, 3:39pm UTC](https://forums.powershell.org/t/help-pwsh-command-wont-take-command-line-arguments/13673/10 "2020-01-22T15:39:17Z")

</div>

I don’t know what this is. I get powershell core here: [GitHub - PowerShell/PowerShell: PowerShell for every system!](https://github.com/PowerShell/PowerShell)

---

<div class="post-metadata">

**Author:** ![nebosite](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@nebosite](https://forums.powershell.org/u/nebosite)\
**Post date:** [January 22, 2020, 4:11pm UTC](https://forums.powershell.org/t/help-pwsh-command-wont-take-command-line-arguments/13673/11 "2020-01-22T16:11:50Z")

</div>

[quote quote=199334]I don’t know what this is. I get powershell core here: [https://github.com/PowerShell/PowerShell](https://github.com/PowerShell/PowerShell)

[/quote]  
Thanks! Installing from the .msi on that page fixed my problem.

---

<div class="post-metadata">

**Author:** ![sobon11859](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@sobon11859](https://forums.powershell.org/u/sobon11859)\
**Post date:** [January 23, 2020, 1:20am UTC](https://forums.powershell.org/t/help-pwsh-command-wont-take-command-line-arguments/13673/12 "2020-01-23T01:20:16Z")

</div>

[Kodi Download](https://kodi.casa/)

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:31pm UTC](https://forums.powershell.org/t/help-pwsh-command-wont-take-command-line-arguments/13673/13 "2024-05-16T20:31:15Z")

</div>


