我是新手powershell。我需要复制整个目录结构从源到目标,文件名匹配一个模式。我正在做以下事情。但它只会复制根目录中的内容。例如
"E:\Workflow\mydirectory\file_3.30.xml"
不会被复制。
这里是我的命令序列。
PS F:\Tools> $source="E:\Workflow"
PS F:\Tools> $destination="E:\3.30"
PS F:\Tools> $filter = [regex] "3.30.xml"
PS F:\Tools> $bin = Get-ChildItem -Path $source | Where-Object {$_.Name -match $filter}
PS F:\Tools> foreach ($item in $bin) {Copy-Item -Path $item.FullName -Destination $destination}
PS F:\Tools> foreach ($item in $bin) {Copy-Item -Path $item.FullName -Destination $destination -recurse}