ファイルとフォルダ含む
Get-ChildItem -Force -Recurse | Get-Acl | Select-object @{Label=”Path”;Expression={Convert-Path $_.Path}}, Owner, AccessToString |Export-Csv C:\Users\TEST\Desktop\list.csv -encoding Default
フォルダのみ
Get-ChildItem -Recurse | where-object {$_.mode -match "d"} | Get-Acl | Select-object @{Label="Path";Expression={Convert-Path $_.Path}}, PSChildName, AccessToString |Export-Csv C:\Users\TEST\Desktop\list.csv -encoding Default
ファイルのみ
Get-ChildItem -Force -Recurse -File | Get-Acl | Select-object @{Label=”Path”;Expression={Convert-Path $_.Path}}, Owner, AccessToString |Export-Csv C:\Users\TEST\Desktop\list.csv -encoding Default
Get-ChildItem
フォルダ下のアイテムを取得します。
where {$_.mode -match “d”}
対象をフォルダのみに絞っています。
ファイルのアクセス権も取得したい場合はこれを抜きます。
Get-Acl
アクセス権情報を取得しています。
Select-object
出力する項目を絞ります。
@{Label=”Path”;Expression={Convert-Path $_.Path}}
フォルダのパス情報を出力します。
PSChildName
フォルダ名を取得する
AccessToString
アクセス権情報を出力します。
Export-Csv
CSVに出力します。
コメント