使用_Filepath远程执行Powershell的参数传递不起作用 [英] Parameter passing for remote execution of powershell using _Filepath not working
问题描述
大家好,
为Powershell脚本传递用于远程执行的参数不起作用
此处,脚本存在于本地计算机上,并且必须在HyperV服务器上创建VM,同时将服务器名作为参数传递给
调用命令-ComputerName OIP-HyperV -FilePath C:\ PSScript \ CreateVM_ORIGINAL.PS1 -ArgumentList"Serv1"
如果使用ScriptBlock在Hyper-V服务器中存在脚本,则相同的代码将起作用.
但我希望使用FilePath(本地计算机中的脚本)也会发生相同的情况.
请帮助....
您需要阅读有关如何使用UNC路径的内容. C:\是本地驱动器,可能存在于另一台计算机上(仅适用于dos/windows),但可能没有相同的数据.您需要使用更严格的路径定义,以更具体地指定路径,即UNC.
http://en.wikipedia.org/wiki/Path_%28computing%29 [ ^ ]
祝你好运!感谢您的所有帮助:-)
Hi all,
Passing parameter for remote execution for powershell script is not working
Here the script is present on local machine and has to create a VM on HyperV server while passing servername as paramanter
Invoke-Command -ComputerName OIP-HyperV -FilePath C:\PSScript\CreateVM_ORIGINAL.PS1 -ArgumentList "Serv1"
same code will work if script present in Hyper-V server by using ScriptBlock
but I want the same to happen using FilePath(script in local machine).
Please help....
You need to read up on how to use UNC path''s. C:\ is a local drive that may exists on another computer (dos/windows only) but likely doesn''t have the same data. You need to use a more rigorous path definition that specifies the path more specifically, which is UNC.
http://en.wikipedia.org/wiki/Path_%28computing%29[^]
Good luck!
The only thing I did is removing double quotes from the argument and it stated working fine!!! thanks for all your help :-)
这篇关于使用_Filepath远程执行Powershell的参数传递不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!