Link to home
Start Free TrialLog in
Avatar of mihalakj
mihalakj

asked on

Can PSEXEC be used to copy a local file to a remote location?

I am trying to write a simple batch file which will use HP's online ILO configuration utility (hponcfg.exe) to add an administrative user to all ILO's in our organization.  

To do this, I need to take a .xml file on one server and copy it to the server I am running psexec on.  I then run another psexec command which uses hponcfg to add the user to the ilo.  The reason I want to use psexec to do the file copy instead of just copying the file outright is because psexec has the "@file" feature which allows you to fee a .txt file with your server list to it.  Using this will allow me to to add the user to all ILO's at once in my organization.  If I use copy, I need to copy this file for each server and I would like to avoid that if possible.

I'm trying to take ilo_update.xml on a server called insightmgr and copy it to the M: drive on a server called citrix-xp02.  Later I run another psexec command which uses hponcfg to reference the ilo_update.xml file, which works flawlessly.

below is the psexec command and error that is returning.  Anyone know what I'm doing wrong?  When I run the command locally on the citrix server it works like a charm!

psexec \\citrix-xp02 -u "domain\user" -p "password" "cmd.exe copy \\insightmgr\c$\downloads\ilo_scripts\ilo_update.xml M:"


PsExec v1.94 - Execute processes remotely
Copyright (C) 2001-2008 Mark Russinovich
Sysinternals - www.sysinternals.com

Starting cmd.exe copy \\insightmgr\c$\downloads\ilo_scripts\ilo_update.xml M: on

PsExec could not start cmd.exe copy \\insightmgr\c$\downloads\ilo_scripts\ilo_up
date.xml M: on citrix-xp02:
The system cannot find the path specified.
ASKER CERTIFIED SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you raise any other batch file issues can I suggest raising them in the MSDOS T/A as there are more experts there

https://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/
Avatar of mihalakj
mihalakj

ASKER

Great Answer, just one comment, need to add a space between the "/d" and "/y" in your code.  see below.

for /f %%a in (servers.txt) do xcopy /d /y c:\sourcfile.xml \\%%a\share\path

I guess I need to work on my windows batch scripting, but I can use that line alot! THANKS!
Sorry about the missing space, was typed quickly from memory. Yes for is REALLy useful.  Have a look at for /?, set /? and if /? for loads of hidden usefulness that doesn't get used enough.

If you get any other batch file question post them in MSDOS area (as the main entry) as the first entry you choose is where the points go... pretty well wasted for me at least in this one.

thanks

Steve