标签: powershell-7

无法使用 Powershell 7 使用 SSH

当我尝试使用 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)

powershell 错误

但它在 cmd 和 windows powershell 上运行良好 使用 CMD 工作 使用 Windows Powershell

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

我尝试将 Openssh 添加到系统路径,安装 openssh 客户端和服务器,但没有成功。

我该如何修复它?

windows ssh openssh powershell-7

5
推荐指数
1
解决办法
485
查看次数

PowerShell 无法根据位置参数的数量选择正确的 ParameterSet

我正在尝试编写一个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 parameter-sets powershell-7

5
推荐指数
1
解决办法
93
查看次数

如何在 powershell 中输入时禁用建议

执行命令时PowerShell它会自动建议文本

在此输入图像描述

我如何禁用这些建议,如果将来我想启用这些建议,我该怎么做?

powershell intellisense interactive psreadline powershell-7

4
推荐指数
1
解决办法
1147
查看次数