问题
I have seen this script https://github.com/danielbohannon/Out-FINcodedCommand/blob/master/README.md
And when I try the the example given I get the error
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
Can you help?
回答1:
Where are you running it. Add .\ in front of it
.\Out-FINcodedCommand.ps1
If it is in a directory that you are not cd to, then the .\ needs to be in front of the whole string
.\Downloads\Out-FINcodedCommand-master\Out-FINcodedCommand-master\Out-FINcodedCommand.ps1
回答2:
To complement SureThing's effective solution with background information:
By design, as a security measure, PowerShell - unlike
cmd.exe
- does NOT invoke executables (which includes scripts) located in the current directory by file name only.- Only executables in the so-called [command-lookup] path can be invoked by file name only, namely only executables located in one of the directories listed in environment variable
Path
($env:PATH
). An example isfindstr.exe
, whose directory,C:\WINDOWS\system32
, is listed in$env:PATH
.
- Only executables in the so-called [command-lookup] path can be invoked by file name only, namely only executables located in one of the directories listed in environment variable
To invoke executables that are not in the command-lookup path, you must use a file path:
The file path may be absolute (full) or relative (and may be based on variables).
Therefore, to invoke a script located in the current directory, prefix the file name with
.\
(.
refers to the current directory), which in the case at hand means.\Out-FINcodedCommand.ps1
来源:https://stackoverflow.com/questions/60255154/out-fincodedcommand-ps1-is-not-recognized-executing-a-script-in-the-current-di