Out-FINcodedCommand.ps1无法识别-在当前目录中执行脚本

问题描述 投票:1回答:2

我看过此脚本https://github.com/danielbohannon/Out-FINcodedCommand/blob/master/README.md

并且当我尝试给出的示例时出现错误

Out-FINcodedCommand.ps1 : The term 'Out-FINcodedCommand.ps1' 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
Out-FINcodedCommand.ps1 -command "iex (iwr https://github.com/danielb ...
CategoryInfo : ObjectNotFound: (Out-FINcodedCommand.ps1:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException

您能帮忙吗?

powershell execution
2个回答
1
投票

您在哪里运行它。在其前面添加。\

.\Out-FINcodedCommand.ps1

如果它不是CD的目录,则。\必须位于整个字符串的前面

.\Downloads\Out-FINcodedCommand-master\Out-FINcodedCommand-master\Out-FINcodedCommand.ps1

0
投票

背景信息补充SureThing's effective solution

  • 通过设计,出于安全考虑,PowerShell-与cmd.exe不同-不通过文件name调用current目录中的可执行文件(包括scripts)仅

    • 仅可以通过文件名调用所谓的[command-lookup] path中的可执行文件,即,仅位于环境变量Path([C0 ])。例如$env:PATH,其目录findstr.exeC:\WINDOWS\system32中列出。
  • 要在命令查找路径中调用not的可执行文件,必须使用文件path

    • 文件路径可能是absolute(完整)或relative(并且可能基于变量)。

    • 因此,调用位于[[current目录中的脚本,在文件名前加上$env:PATH.\指当前目录),在当前情况下,这意味着.

© www.soinside.com 2019 - 2024. All rights reserved.