views:

631

answers:

1

Im trying to take the conents of a folder and copy it to a another unis powershell 1.0. Pretty simple stuff and all works fine using Copy-Item $from $to -recurse if I am copying from a local folder to a local folder, however if the $to variable is a UNC path it seems to copy the $from directory, not just its contents

eg
$from = "c:\temp\rhysc\"
$to = "\\OtherMachineName\ShareFolder\"
Copy-Item $from $to -recurse

..Ends up up creating a folder \OtherMachineName\ShareFolder\rhysc instead of just copying over the contents of the folder.

I want to maintain the structure of the from directory that i am copying over so my basic attempt at piping didnt work (everything got dumped in the root of the $to folder)
Get-ChildItem $from -recurse | Copy-Item -destination $to

Any help is appreciated :)

+2  A: 

Try:

$from = "c:\temp\rhysc\*"

David Tchepak
I feel stupid, and i love you. cheers!
RhysC