Created
December 6, 2015 04:15
-
-
Save jllwebgit/2b15d12b6c084b6b83ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$array = New-Object System.Collections.ArrayList | |
#アクセス権一覧を取得するパス | |
$targetDir = "C:\" | |
#結果を出力するCSVパス | |
$exportCSVPath = "D:\acl.csv" | |
#全てのサブディレクトリのみ | |
#ファイルも出力したい場合には、「 Where { $_.PSIsContainer } |」を | |
#削除する | |
Get-ChildItem -Recurse -Path $targetDir | Where { $_.PSIsContainer } | | |
forEach { | |
$objPath = $_.FullName | |
$coLACL = Get-Acl -Path $objPath | |
forEach ( $objACL in $colACL ) { | |
forEach ( $accessRight in $objACL.Access ) { | |
$array.add($objPath + "," + ` | |
$accessRight.IdentityReference + "," + ` | |
$accessRight.FileSystemRights + "," + ` | |
$accessRight.AccessControlType + "," + ` | |
$accessRight.IsInherited + "," + ` | |
$accessRight.InheritanceFlags + "," + ` | |
$objACL.AreAccessRulesProtected ` | |
) | |
} | |
} | |
} | |
#リストをソート | |
$array.Sort() | |
#1行目に項目をInsert | |
$array.insert(0,"Path,` | |
IdentityReference,` | |
FileSystemRights,` | |
AccessControlType,` | |
IsInherited,` | |
InheritanceFlags,` | |
AreAccessRulesProtected"` | |
) | |
$array > $exportCSVPath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment