How to copy folder with subfolders? [duplicate]

瘦欲@ 提交于 2019-12-03 05:22:20

PowerTip: Use PowerShell to Copy Items and Retain Folder Structure

Source: https://blogs.technet.microsoft.com/heyscriptingguy/2013/07/04/powertip-use-powershell-to-copy-items-and-retain-folder-structure/

Question: How can I use Windows PowerShell 3.0 to copy a folder structure from a drive to a network share, and retain the original structure?

Answer: Use the Copy-Item cmdlet and specify the –Container switched parameter:

$sourceRoot = "C:\temp"
$destinationRoot = "C:\n"

Copy-Item -Path $sourceRoot -Filter "*.txt" -Recurse -Destination $destinationRoot -Container
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!