0

I Have power shell script which runs fine when it is located on local computer. if i run test.ps1 file, it executes. Test.ps1 has a code to use current working directory and reads xml file from current working directory

When i'm trying to use invoke-command and run this script from file share i'm receiving error message unable to find path or so .. here is my syntax:

Invoke-command -computername "test1" -filepath "\\xyz\test\test.ps1"

above syntax didn't work...

then i tried couple of things like

invoke-command -computername "test1" -scriptblock{\\xyz\test\test.ps1}

and

invoke-command -computername "test1" -scriptblock{(param $x) \\xyz\test\test.ps1} -Argumentlist $scriptroot

None of them worked..

Tony Hinkle
  • 4,706
  • 7
  • 23
  • 35
  • 4
    "did not work" is not explanation of a problem. Please provide exact error messages as well as small sample script that demonstrates the problem. – Alexei Levenkov Sep 15 '15 at 15:00
  • Do you have a drive letter in -filepath, or did you just leave that out when you posted it? – Tony Hinkle Sep 15 '15 at 15:35
  • @AlexeiLevenkov The issue _appears_ to be using the relative paths. Also the OP does put the error in the questions _i'm receiving error message unable to find path_. Perhaps there is more information but that could be enough to form a potential solution. – Matt Sep 15 '15 at 15:35
  • @Matt "unable to find path or so"... and answer should be "probably relative paths issue or anything else"? If you can provide god answer - why not to do so instead of comment? – Alexei Levenkov Sep 15 '15 at 15:42
  • @AlexeiLevenkov Because I am at work and unable to test to prove my theory. While the question has its issues it didn't deserve to be closed just yet. – Matt Sep 15 '15 at 15:44
  • @Matt I did not know that powershell tag have different rules... Most other once require proper details/MVCE. This question should be fine than (Also I'll keep my vote) – Alexei Levenkov Sep 15 '15 at 15:48
  • @AlexeiLevenkov This tags rules are not different? More information would have helped but this one has enough to get the jist of the issue. Code, situation and an error. Its weak but it works. I don't expect the first question to be stupendous – Matt Sep 15 '15 at 16:00
  • https://msdn.microsoft.com/en-us/library/windows/desktop/ee309365%28v=vs.85%29.aspx – Ansgar Wiechers Sep 15 '15 at 16:47
  • Do you want to run the script on local machine just from remote location or do you want to run the script on remote machine? If you need former, you don't need to use `Invoke-Command`. – n0rd Sep 15 '15 at 17:54
  • Error message Cannot bind argument to parameter because it is null – scriptbegiiner Sep 15 '15 at 19:02
  • Please, don't put updates into comments, edit your question instead. – n0rd Sep 15 '15 at 19:04
  • canot find the path because it doesn't exists is the error message for the following command invoke-command -computername "test1" -scriptblock{\\xyz\test\test.ps1} – scriptbegiiner Sep 15 '15 at 19:07
  • http://stackoverflow.com/questions/7794206/powershell-remote-script-access-denied-to-network-resources – n0rd Sep 15 '15 at 19:21

0 Answers0