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
Solved

Execute a PowerShell script on a remote machine with PSExec

Posted on 2014-01-29
4
4,775 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
  • 2
4 Comments
 
LVL 70

Accepted Solution

by:
Chris Dent earned 500 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
A procedure for exporting installed hotfix details of remote computers using powershell
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

829 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