码迷,mamicode.com
首页 > 其他好文 > 详细

导出目录权限

时间:2016-05-30 17:11:53      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:

导出某个目录下所有文件夹权限,每个目录权限对应一个csv文件

$sfolder = "D:\FileShare\finance dep"
$folders = gci $sfolder -Recurse | ? {$_.Mode -eq "d----"}

$rfolder = "D:\Operations\Scripts\finance-p"

foreach ($folder in $folders)
{
$f = $folder.fullname
$acls = Get-Acl $f |select *
$foldernamer = $acls.Path.Split("::")[3].replace("\","-")
$foldername = $foldernamer.substring(1,$foldernamer.length-1) + ".csv"
$folderpath = Join-Path $rfolder $foldername
foreach($p in $acls.Accesstostring.split("`n"))
    {
  if($p.Contains("UXIN") -and (!$p.contains("Admin")))
        {
        $ps = $p.Split(" ")
        $pcount = $p.Split(" ").length
        $ps[0] + "," + $ps[1..($pcount-1)] -join " " |Out-File $folderpath -Encoding UTF8 -Append
        }
  
    }


}

 

导出目录权限

标签:

原文地址:http://www.cnblogs.com/dreamer-fish/p/5543129.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!