当我尝试使用 powershell 7 来使用 ssh 时,它会抛出错误:
ssh: The term 'ssh' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Run Code Online (Sandbox Code Playgroud)
但它在 cmd 和 windows powershell 上运行良好

我还注意到我无法将目录更改为 OpenSSH (C:\Windows\System32\OpenSSH)

我尝试将 Openssh 添加到系统路径,安装 openssh 客户端和服务器,但没有成功。
我该如何修复它?
我正在尝试编写一个Set-MyRef使用 ParameterSets 来公开其可用参数的 PowerShell 函数。我希望该函数具有类似于以下内容的参数集:
Set-MyRef -Latest
Set-MyRef -LocalBranch
Set-MyRef [-Tag] <string>
Set-MyRef [-Env] <string> -LocalBranch
Set-MyRef [-Env] <string> -Latest
Set-MyRef [-Env] <string> [-Tag] <string>
Run Code Online (Sandbox Code Playgroud)
也就是说,恰好有一个 options -Latest,-LocalBranch或者-Tag可以给出一个可选的-Env作为第一个位置参数。
重要的是,我希望Set-MyRef 'foo'被解析为-Tag 'foo',并被Set-MyRef 'foo' 'bar'解析为-Env 'foo' -Tag 'bar'.
我尝试使用 ParameterSets 来实现它:
function Set-MyRef {
[CmdletBinding()]
param (
[Parameter(Position = 0, Mandatory = $true, ParameterSetName = 'EnvTag')]
[Parameter(Position = 0, Mandatory = $true, ParameterSetName = 'EnvLatest')] …Run Code Online (Sandbox Code Playgroud) powershell-7 ×3
powershell ×2
intellisense ×1
interactive ×1
openssh ×1
psreadline ×1
ssh ×1
windows ×1