PS C:\> gci a -Recurse | select -expa FullName
C:\a\lib
C:\a\lib\foo
C:\a\lib\foo.txt
C:\a\lib\foo\bar.txt
PS C:\> gci b -Recurse | select -expa FullName
PS C:\> Copy-Item -Path "C:\a\lib" -Destination "C:\b" -Recurse -Force
PS C:\> gci b -Recurse | select -expa FullName
C:\b\lib
C:\b\lib\foo
C:\b\lib\foo.txt
C:\b\lib\foo\bar.txt
PS C:\> Remove-Item C:\b\lib\foo -Recurse -Force
PS C:\> gci b -Recurse | select -expa FullName
C:\b\lib
C:\b\lib\foo.txt
PS C:\> Copy-Item -Path "C:\a\lib" -Destination "C:\b" -Recurse -Force
PS C:\> gci b -Recurse | select -expa FullName
C:\b\lib
C:\b\lib\foo
C:\b\lib\foo.txt
C:\b\lib\foo\bar.txt
PS C:\>
And note that you can test most cmdlets changing something using the -WhatIf argument.
This will not actually copy anything; remove the -WhatIf at the end to run it for real:
Open in new window