powershell遍历文件夹设置权限,解决文件无法删除的问题。

function set-rights ($path) {
    $p = Get-Item $path;
    if ($p.Attributes -eq 'Directory') {
        foreach ($child in Get-ChildItem $p.FullName) {
            set-X($child.FullName);
        }
    }
    icacls $p.FullName /grant 'everyone:f';
}

$path="E:\abc";
set-rights($t);

 

posted @ 2018-01-13 13:33  mokeyish  阅读(1013)  评论(0编辑  收藏  举报