Powershell &引用;“未找到文件”;不能将Invoke SCScriptCommand与cmd.exe+;args
我为Microsoft System Center Virtual Machine Manager制作了一个插件,它通过由插件的c#代码调用的powershell脚本在主机上执行powershell脚本。(P) 由于我总是遇到一个错误,所以我决定在SCVMM中手动测试它,方法是右键单击主机并输入可执行文件的Powershell &引用;“未找到文件”;不能将Invoke SCScriptCommand与cmd.exe+;args,powershell,system-center,Powershell,System Center,我为Microsoft System Center Virtual Machine Manager制作了一个插件,它通过由插件的c#代码调用的powershell脚本在主机上执行powershell脚本。(P) 由于我总是遇到一个错误,所以我决定在SCVMM中手动测试它,方法是右键单击主机并输入可执行文件的powershell.exe或powershell,以及export-v-name[name]-path[path]-force-copystate-wait。 现在它告诉我没有这样的文件。
powershell.exe
或powershell
,以及export-v-name[name]-path[path]-force-copystate-wait
。
现在它告诉我没有这样的文件。
奇怪的是,它与cmd
(.exe
)和回声测试一起工作。
powershell不应该安装在Windows Server 2012上吗?
此外,如果我远程控制主机,它在控制台中也可以正常工作。
我缺少什么?我发现在将powershell.exe用作可执行文件时,需要提供完整路径。问题在于并非所有主机都具有包含powershell.exe可执行文件路径的系统变量路径
您可以通过提供完整路径来运行powershell.exe:
%WINDIR%\System32\WindowsPowerShell\v1.0\PowerShell.exe
或者,您可以将cmd.exe作为可执行文件运行,然后从此cmd运行powershell.exe:
可执行文件:cmd.exe
参数:/c powershell.exe echo 1;返回0