Copy-item issues

by sabeltiger81 at 2013-04-04 04:02:41

I use a Server 2008R2 server to copy a folder from one 2003 server to another 2003 server. for this I use powershell and it works fine, although i am in doubt wether it will copy the same files from source to destination next time i run the script?

And also I would like to see how it goes by either a write-host command or log file.

The log file is my next issue, I have tried to create a logfile for C:\logfile.txt but it’s empty.

A third thing when I copy from source to destination the folder at the destination doesn’t update the date for changes in the windows library overview, why is that? Shouldn’t it update the date if I copy the files and they make an overwrite to existing files?

copy-item \server1\c$\webfolder\Sharedfolder\MyFolder -Destination \server3\c$\webfolder\Sharedfolder\NewFolder -recursive
by DonJ at 2013-04-04 08:11:46
Copy won’t overwrite existing items by default - it’ll return an error. Copy-Item also doesn’t provide any per-item progress, so you can’t see it go by using Write-Host or anyting else. You can try adding -verbose to see if it produces its own progress output.

Without knowing how you tried to create a log file, I can’t guess what it didn’t work.

You might consider using Robocopy instead. I think it’ll do a lot more of what you’re looking for.
by sabeltiger81 at 2013-04-08 01:25:14
I can tell you that, -Verbose worked.

But how to make the script create a logfile. The reason I ask is that Copy-item isn’t that great when creating logfiles let’s say with start/stop-transcript