【问题标题】:How I can copy Data recursive from position A to position B with Powershell?如何使用Powershell将数据递归从位置A复制到位置B?
【发布时间】:2015-02-26 10:01:47
【问题描述】:

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

这必须使用 UNC-Paths 来完成。

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

我不知道如何开始:/

【问题讨论】:

    标签: windows file powershell transfer unc


    【解决方案1】:

    在本例中,位置 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 $_}}
    

    【讨论】:

    • 是的,这是在具有不同计算机的网络中。我想将文件夹和子文件夹中的所有文件复制到其他位置。 ^^
    • 编辑了我的帖子,这应该就是你所需要的。
    猜你喜欢
    • 1970-01-01
    • 2017-04-23
    • 2012-11-15
    • 1970-01-01
    • 1970-01-01
    • 2020-04-02
    • 1970-01-01
    • 2020-09-23
    • 1970-01-01
    相关资源
    最近更新 更多