如何使用 Powershell 将数据从位置 A 递归复制到位置 B?

How I can copy Data recursive from position A to position B with Powershell?

我想创建一个 powershell 脚本,它可以递归地将数据从位置 a 复制到位置 b。

这必须使用 UNC 路径来完成。

位置b必须所有空订单删除。

我不知道如何开始:/

在此示例中,位置 A 和位置 B 都需要是给定服务器上的本地路径或共享。

$a = '\serverA\folderA'
$b = '\serverB\folderB'

#This copies the files
Get-ChildItem $a -Recurse -File | Foreach_Object {Copy-Item $_ -Destination $b}

#Removes empty files
Get-ChildItem $b -File | Foreach-Object {IF($_.Length -eq 0) {Remove-Item $_}}