How can I copy all files that match a filter and the directory structure to UNC path will powershell:

For example with the filter as "*2011_01_02*.bak":

\arf.2011_01_02.bak
\foo\baz\arf.2011_01_02.bak

To \\192.168.1.1\meow\ with the result of:

\\192.168.1.1\meow\arf.2011_01_02.bak
\\192.168.1.1\meow\foo\baz\arf.2011_01_02.bak
link|improve this question

78% accept rate
It sounds like it's raining cats and dogs over by you guys... – Holocryptic May 20 '11 at 16:23
feedback

2 Answers

How about:

Copy-Item . -Destination "\\192.168.1.1\meow\" -Filter "*2011_01_02*.bak" -Recurse

(Based on some fiddling on a test box.)

link|improve this answer
feedback

Using robocopy, something like the following does the trick:

Robocopy.exe .\ \\192.168.1.1\meow *.ps1 /S

Not powershell, but seems to do the trick.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.