I have a linux server with winexe package installed. It's the same as PSExec, and everything works okay when running simple commands, but when I run it with this command below I get a parsing error!

winexe -U user%password //host "powershell -Command (New-Object System.Net.WebClient).DownloadFile("http://host/filename.iso","c:\file.iso")"

Can anyone figure what's wrong with this? Is it's cause a conflict in the quotes around the url and file name, with the quotes around the whole command?

  • 1
    Can you post the full error message? – cpast Mar 18 '13 at 22:07

Try using the format: powershell.exe -Command "& {<command>}"

This worked for me, using your example:

powershell.exe -Command "& {(New-Object System.Net.WebClient).DownloadFile('http://google.com/robots.txt','c:\robots.txt')}"

Also, I used single-quotes in DownloadFile

Reference: http://technet.microsoft.com/en-us/library/hh847736.aspx


Nested use of double quotes won't work. Try something like this:

winexe -U user%password //host "powershell -Command (New-Object System.Net.WebClient).DownloadFile('http://host/filename.iso','c:\file.iso')"

The easiest way is to run the command directly using single quote. For example listing the processes can be done as follows:

winexe -U "Domain\PC-Name" //IP Address 'powershell.exe Get-Process'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.