Execute a PowerShell script on a remote machine with PSExec

Hello. I have a PowerShell script on several remote machines that I would like to execute with PSExec (Windows Remote Management is not an option). The script is on the E: drive. When I run the below command from my machine, I get this error Processing -file 'e:\copy.ps1' failed because the file does not have a '.ps1' extension. Specify a valid PowerShell script file name, and then try again.

psexec \\server1 cmd /c "echo . | powershell -file e:\copy.psl"

What am I missing?
LorrecAsked:
Who is Participating?
 
Chris DentPowerShell DeveloperCommented:
It took a moment or two to see this, but you named your file e:\copy.PSL (upper-case because lower really doesn't help show this).

It needs to be PS1 (numeric 1).

Chris
0
 
LorrecAuthor Commented:
Wow. I feel stupid and must be losing it. Not sure how I missed that. Thank you for the quick response.
0
 
LorrecAuthor Commented:
Thank you
0
 
pcelbaCommented:
Fantastic!  I mean the  echo.  I've been investigating long minutes how to force powershell to exit on remote machine.

Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.