【问题标题】:Copy a windows folder with its permissions but without overwritting the content复制具有权限但不覆盖内容的 windows 文件夹
【发布时间】:2013-01-23 00:14:57
【问题描述】:

我想复制具有权限但不复制其内容的文件夹。举个例子:

C:\pictures and it has cat photos in it

我只想复制权限

D:\pictures (has other pictures)

我想把它复制到

E:\pictures (this folder is not existing)

我用robocopyicacls 尝试过。但我无法使用 icacls 恢复数据:

icacls C:\pictures /save ntfspermissions.txt /c
icacls D:\pictures /restore C:\ntfspermissions.txt

它只是说:1 error

在 robocopy 中,我使用参数“/COPY:SAO”进行了尝试。但它也不起作用。它仅适用于“/MIR”,但如果我这样做,我也会复制内容。

【问题讨论】:

    标签: windows batch-file permissions directory


    【解决方案1】:

    使用 get-acl 和 set-acl :

    $acl=get-acl -path C:\pictures
    set-acl -path d:\pictures -AclObject $acl
    New-Item -ItemType directory -Name pictures -Path e:\
    set-acl -path e:\pictures -AclObject $acl
    

    Don Jones 的更详细回答:http://technet.microsoft.com/en-us/magazine/2008.02.powershell.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-26
      • 2015-04-05
      • 2021-04-01
      • 2015-09-07
      • 2018-05-20
      • 1970-01-01
      • 2013-03-14
      • 2018-05-19
      相关资源
      最近更新 更多