各位大神
我想匯出服務器前三層檔案夾的子檔案夾權限,但是foreach會遍歷所有子檔案夾,所以會很龐大,
怎么第三層檔案夾就退出foreach
#使用Get-ChildItem獲取需要查找權限的檔案及檔案夾
Get-ChildItem 'C:\Users\LiM\Documents\Software' -Recurse -Force |`
ForEach-Object {
$i = $_
#使用System.IO.FileInfo.GetAccessControl().Access
$_.GetAccessControl().Access |`
Select-Object @{n="Path";e={$i.fullname}}, @{n="User";e={$_.IdentityReference}}, `
@{n="Permission";e={$_.FileSystemRights}}, @{n="Permission Type";e={$_.AccessControlType}}, `
@{n="IsInherited";e={$_.IsInherited}}
} |`
Export-Csv C:\Users\LiM\Documents\user.csv -Encoding UTF8 -NoTypeInformation
uj5u.com熱心網友回復:
沒用過foreach,看回圈有沒其他引數了轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/25487.html
