I need to copy all *.doc
files (but not folders whose names match *.doc
) from a network folder \\\\server\\source
(including files in
# Get all *.doc files under \\server\source
Get-ChildItem -Path \\server\source *.doc -Recurse |
# Filter out directores
Where-Object { -not $_.PsIsContainer } |
# Add property for destination
Add-Member ScriptProperty -Name Destination -Value { Join-Path 'C:\destination' $this.Name } -PassThru |
# Filter out files that exist on the destination
Where-Object { -not (Test-Path -Path $_.Destination -PathType Leaf } |
# Copy.
Copy-Item