0

I have just installed the open-source version of PowerShell for Linux on Arch Linux using the powershell-git package from AUR. When I try PowerShell's -Version functionality, I get the following:

PS /home/user> powershell -Version 5.1                                          
-Version : The term '-Version' is not recognized as the name of a cmdlet, 
function, script file, or operable program. Check the spelling of the name, or 
if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ -Version 5.1
+ ~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (-Version:String) [], CommandNot 
   FoundException
    + FullyQualifiedErrorId : CommandNotFoundException

How to fix this?

0

PowerShell was written for Windows, which assumes an underlying filesystem where case does not matter. When you enter a PowerShell command, the program reads whatever you type, and then matches it against its idea of what the case ought to be and redisplays that.

The help-message for PowerShell shows the option as -Version:

-Version
    Starts the specified version of Windows PowerShell. 
    Enter a version number with the parameter, such as "-version 2.0".

The error message is saying that it expected to find a match using the filesystem's notion of the fully-spelled name. You will probably have better success if you use the mixed-case names as indicated in the help-message.

  • This does not work either. – ThePiercingPrince Aug 31 '16 at 9:22
  • 3
    Raise a bug report. It is an alpha release, after all. – fpmurphy Aug 31 '16 at 11:06
0

On Ubuntu seems to work fine:

thufir@dur:~$ 
thufir@dur:~$ pwsh
PowerShell v6.0.1
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /home/thufir> 
PS /home/thufir> $PSVersionTable.PSVersion                                                                              

Major  Minor  Patch  PreReleas BuildLabel 
                     eLabel               
-----  -----  -----  --------- ---------- 
6      0      1                           


PS /home/thufir> 
PS /home/thufir> get-host                                                                                               


Name             : ConsoleHost
Version          : 6.0.1
InstanceId       : 914b71f4-0e73-461c-b1c3-f04753e5ed34
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-CA
CurrentUICulture : en-CA
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace



PS /home/thufir> 
PS /home/thufir> $PSVersionTable                                                                                        

Name                           Value                                                                                   
----                           -----                                                                                   
PSVersion                      6.0.1                                                                                   
PSEdition                      Core                                                                                    
GitCommitId                    v6.0.1                                                                                  
OS                             Linux 4.13.0-32-generic #35-Ubuntu SMP Thu Jan 25 09:13:46 UTC 2018                     
Platform                       Unix                                                                                    
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                 
PSRemotingProtocolVersion      2.3                                                                                     
SerializationVersion           1.1.0.1                                                                                 
WSManStackVersion              3.0                                                                                     


PS /home/thufir> 
PS /home/thufir> exit                                                                                                   
thufir@dur:~$ 
thufir@dur:~$ pwsh hello_world.ps1 
hello powershell world
thufir@dur:~$ 
thufir@dur:~$ ./hello_world.ps1 
hello powershell world
thufir@dur:~$ 
thufir@dur:~$ cat hello_world.ps1 
#!/usr/bin/pwsh -Command


"hello powershell world"
thufir@dur:~$ 

you'll have to clarify the problem. You can't find the version for pwsh?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.