Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Copy-Item Not Working in Powershell Script

$
0
0

I have a Powershell script that contains the lines [masked out actual directory and server name]:

Copy-item C:\ProgramData\dir1\dir2\abc_config.xml \\server2\c$\ProgramData\dir1\dir2\abc_config.xml -force -passThru
Copy-item C:\Users\All Users\dir1\dir2\abc_config.xml \\server2\c$\Users\All Users\dir1\dir2\abc_config.xml -force -passThru

Execution of the script in ISE will display the above lines, and the $? will return TRUE as if all went fine.  When I check server2, the file has not been updated.

Now, if I copy/paste the above lines in ISE, it works.  Server2 willl show the updated file.  It is the same account in ISE that I am using to run the script, and copy/paste the commmand.  Do I need to do something to get the script working?


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>