?
Solved

Execute a PowerShell script on a remote machine with PSExec

Posted on 2014-01-29
4
Medium Priority
?
5,499 Views
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?
0
Comment
Question by:Lorrec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 71

Accepted Solution

by:
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).

Chris
0
 

Author Comment

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

Author Closing Comment

by:Lorrec
ID: 39821329
Thank you
0
 
LVL 42

Expert Comment

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

Thanks!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

771 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