1

Quite simply:

> powershell.exe -command "& '\\RemoteServer\c$\My Script.ps1'"

does not work at all. My Script.ps1 opens in Notepad, nothing more. Meanwhile,

> powershell
PS > &"\\RemoteServer\c$\My Script.ps1"

works just fine (the script executes).

I did have to use the caspol tool, since my script relies on a binary module, but I don't see how that could be the issue.

Any thoughts as to the cause of this issue?

Thanks!

3 Answers 3

1

Try...

powershell.exe . '\\RemoteServer\c$\My Script.ps1'
Sign up to request clarification or add additional context in comments.

Comments

1

Try...

powershell.exe -nologo -command "&{\\RemoteServer\c$\My Script.ps1}"

Comments

0

Perhaps your problem is the white space in your script name, here is a solution if you want to call from cmd.exe :

C:\>powershell.exe -nologo -command "&{$a=\"\\RemoteServer\c$\My Script.ps1\";& $a}"

\" prevent cmd.exe from interpreting " character

If you want to execute it into a powershell.exe command prompt :

PS C:\>powershell.exe -nologo -command "&{`$a='\\WM2008R2ENT\c$\temp\Aff le loup.ps1';& `$a}"

$ prevent powershell.exe from interpreting$` character

Hope it helps

JP

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.