Я только что установил версию PowerShell для Linux с открытым исходным кодом на Arch Linux, используя ] powershell-git пакет из AUR . Когда я пробую функциональность PowerShell -версия
, я получаю следующее:
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
Как это исправить?
En Ubuntu parece que funciona bien:
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:~$
tendrás que aclarar el problema. ¿No puede encontrar la versión para pwsh
?