【发布时间】:2013-12-27 16:25:06
【问题描述】:
鉴于我的文件系统上有以下say-hello.ps1 文件:
function SayHello()
{
return "Hello World!"
}
像这样在命令行上调用(它最终将作为 Windows 计划任务运行):
powershell -ExecutionPolicy unrestricted -command "& { c:\say-hello.ps1; SayHello }"
为什么我会得到以下结果?
SayHello : The term 'SayHello' 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:33
+ & { c:\say-hello.ps1; SayHello }
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (SayHello:String) [], CommandNot
FoundException
+ FullyQualifiedErrorId : CommandNotFoundException
【问题讨论】:
标签: powershell cmd