I need to copy all *.doc files (but not folders whose names match *.doc) from a network folder \\\\server\\source (including files in
Why use foreach when you already have a pipeline? Calculated properties for the win!
Get-ChildItem -Recurse -Path:\\Server\Path -filter:'*.doc' |
Where { -not $_.PSIsContainer } |
Group Name |
Select @{Name='Path'; Expression={$_.Group[0].FullName}},@{Name='Destination'; Expression={'C:\Destination\{0}' -f $_.Name}} |
Copy-Item