I'm trying to send the "copy-item" command using xp_cmdshell to move an item I encrypt earlier in a sproc. In the sproc I create a .bat file, executed as a scheduled task, to do the encryption.
I've tried using the same method to execute the copy-item command, as well as a basic EXEC xp_cmdshell command and neither is working. Any idea why it would work to exec gpg, but not when i try to exec the copy-item command?
Here's what I've tried:
set @cmd = 'copy-file c:\MissionControlDocs\'+@docFolder+@rawfilenamewoext+'.txt.gpg y:\aep-ohio>> ' + @batchFileName)
exec master..xp_cmdshell @cmd, no_output
and selecting the command into a batch file, then calling the task (which runs successfully on the server):
select @cmd = rtrim('echo copy-file c:\MissionControlDocs\'+@docFolder+@rawfilenamewoext+'.txt.gpg y:\aep-ohio>> ' + @batchFileName)
exec master..xp_cmdshell @cmd, no_output
Copy-file works when I run it directly in the powershell application on the server - no matter what directory I'm currently in.
Your thoughts are greatly appreciated.