I am trying to create a job that will execute a batch file remotely. I am able to run a batch file no problem with this command.
Invoke-Command-ComputerNameDDS {CMD/cD:\COWWW\Batches\test.bat}
This is the batch files contents : @ECHO this is a test.
However, the problem I am running into is when I execute a batch file with much more complex commands. When I run this batch file I receive the following error.
@ECHO Working.....Please be patient....
sqlcmd.exe -E -S DDS\DDS -d cowww -i C:\Users\Administrator\Desktop\SQL\usp_CoWWW_cleanup.sql -p -o D:\websites\Logs\System\Eventlog\CoWWW_cleanup.log
FOR %%A IN (%Date%) DO (FOR /F "tokens=1-3 delims=/-" %%B in ("%%~A") DO (SET Today=%%B%%C%%D))
ren D:\websites\Logs\System\Eventlog\CoWWW_cleanup.log CoWWW_cleanup%today%.log
@ECHO SQL Stored Procedure completed, Please check the Log File for Errors.
@ECHO D:\websites\Logs\System\Eventlog\CoWWW_cleanup_log.txt
pause
A duplicate file name exists, or the file + CategoryInfo : NotSpecified: (A duplicate fil...ts, or the file:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError + PSComputerName : DDS cannot be found.