Quantcast
Channel: Spiceworks Community - Latest topics
Viewing all articles
Browse latest Browse all 184296

Powershell - Overwriting File At Destination

$
0
0

I want to copy a file to a destination via PowerShell script so I can schedule it to run every so often. I did a search and found this:

[System.IO.File]::Copy("I:\All\Applications\Schedule\directoryname\filename.xls","C:\Users\username\directoryname\Documents\Cabot S\filename.xls");

It copied the file over just fine but if I ran it again, it would not overwrite it. So, I did a search for a way to overwrite it with this command and nothing could be easily found. I tried the -force command but it kept erroring out.

I also tried: Copy-Item -force("I:\All\Applications\Schedule\directoryname\filename.xls","C:\Users\username\directoryname\Documents\Cabot S\filename.xls");

And it did not work...

I tried looking for an answer by searching with no luck. I also hit up the official TechNet scripting forum and those guys can get a little cranky and never really help. They told me to look at this article:

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

I found no easy help in that article.

Any suggestions?


Viewing all articles
Browse latest Browse all 184296

Trending Articles



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