我有这个powershell脚本(test1.ps1)调用另一个PowerShell脚本(test2.ps1)来完成这项工作 .
两个脚本文件都在同一个文件夹中
test1.ps1
echo "from test1.ps1"
.\test2.ps1
test2.ps1
echo "from test2.ps1"
当我通过创建运行空间在C#中调用test1.ps1,向管道添加命令并调用它时,我收到一条错误消息,提示 "The term '.\test2.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."
1 回答
这两个脚本可能位于同一个文件夹中,但
.\test2.ps1
将在与调用应用程序相同的文件夹中查找test2.ps1,即C#应用程序 .在test.ps1中有这个: