Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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....
Posted

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!
 
Share this answer
 
Comments
Krishnamurthy M 28-Oct-12 12:15pm    
The same command will execute fine if we done pass the parameters and hardcode the values inside the script.
This path C:\PSScript\CreateVM_ORIGINAL.PS1 is present on the same local machine where code is getting executed so I dont think it is a problem.
The main thing is as I told I am not able to pass the paramaeter using -FilePath command.
Please help me if you know how to pass the parameter when using -Filepath command for remote exection.
The only thing I did is removing double quotes from the argument and it stated working fine!!! thanks for all your help :-)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900