Execute a PowerShell script on a remote machine with PSExec

Posted on 2014-01-29
Medium Priority
Last Modified: 2014-09-17
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?
Question by:Lorrec
  • 2
LVL 71

Accepted Solution

Chris Dent earned 2000 total points
ID: 39820602
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).


Author Comment

ID: 39821327
Wow. I feel stupid and must be losing it. Not sure how I missed that. Thank you for the quick response.

Author Closing Comment

ID: 39821329
Thank you
LVL 43

Expert Comment

ID: 40329262
Fantastic!  I mean the  echo.  I've been investigating long minutes how to force powershell to exit on remote machine.


Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

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.

Join & Write a Comment

Considering today’s continual security threats, which affect Information technology networks and systems worldwide, it is very important to practice basic security awareness. A normal system user can secure himself or herself by following these simp…
Welcome to 2018! Exciting things lie ahead in the world of tech. To start things off, we compiled great member articles on how to stay safe, ways to learn, and much more! Read on to start your new year right.
Screencast - Getting to Know the Pipeline
Did you know PowerShell can save you time with SaaS platforms? Simply leverage RESTfulAPIs to build your own PowerShell modules. These will kill repetitive tickets and tabs, using the command Invoke-RestMethod. Tune into this webinar to learn how…

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question