views:

9

answers:

1

I'm trying to copy a single file using copy-item to a remote computer using powershell. It works fine if the directory already exists but fails if it doesn't. I know -force works if it is a directory to a directory but fails if it's a single file. Is there a way to get copy-item to create the destination path without doing a test-path and new-item?

copy-item "\\server1\Upgrade.exe" "\\computer1\c$\temp\" -Force

Edit: I just decided to go with xcopy. Seems to work better.

A: 

I did eventually get this to work by doing the following

Copy-Item "\\server1\Upgrade.exe" -Destination "\\chomputers1\c$\temp" -Force
DTown

related questions