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

Out-FINcodedCommand.ps1 is not recognized - executing a script in the current directory

我看过这个脚本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

你能帮忙吗?

你在哪运行呢。在其前面添加 .\

.\Out-FINcodedCommand.ps1

如果它位于您未 cd 到的目录中,则 .\ 需要位于整个字符串的前面

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

背景信息补充:

  • 根据设计,作为一项安全措施,PowerShell - 与 cmd.exe 不同 - 不会调用可执行文件(包括 脚本 ) 位于 current 目录中,文件 name only.

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

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

    • 因此,要调用位于 当前 目录中的脚本,请在文件名前加上 .\. 指的是当前目录),在本例中表示
      .\Out-FINcodedCommand.ps1