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..

13
  • 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. Commented Sep 15, 2015 at 15:00
  • Do you have a drive letter in -filepath, or did you just leave that out when you posted it? Commented Sep 15, 2015 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. Commented Sep 15, 2015 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? Commented Sep 15, 2015 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. Commented Sep 15, 2015 at 15:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.