1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Format-listのプロパティ*指定

Posted at

前書き

PowershellでNTFSアクセス権の出力コマンド調べてたらFormat-listのプロパティ *指定なるものがあることを知ったので覚書程度にメモすることにした。

本題

プロパティのリストがたくさん出るからよく使っていたが、
-Property *で表示できるプロパティを増やせる場合があることを今更知った。

Get-Aclで比較してみると以下の通り

*なし(Get-Acl | Format-List)
 Path 、Owner、Group、access、Audit、Sddl、

*あり(Get-Acl | Format-List -Property *)
PSPath、PSParentPath、PSChildName、PSDrive、PSProvider、CentralAccessPolicyId
CentralAccessPolicyName、Path、Owner、Group、Access、Sddl、AccessToString
AuditToString、AccessRightType、AccessRuleType、AreAccessRulesProtected、AreAuditRulesProtected、AreAccessRulesCanonical、AreAuditRulesCanonical

もうぱっと見でも項目数に差があるのがわかる。
(詳細情報の更に詳細とか知らんよ)

更に凶悪なのがなしとありで結果が変わることがあるようで、

PS C:\bin> Get-Acl | format-list

Access : BUILTIN\Administrators Allow  FullControl
         NT AUTHORITY\SYSTEM Allow  FullControl
         BUILTIN\Users Allow  ReadAndExecute, Synchronize

PS C:\bin> Get-Acl | format-list *

Access: {System.Security.AccessControl.FileSystemAccessRule, System.Security.AccessControl.FileSystemAccessRule, System.Security.AccessControl.FileSystemAccessRule, System.Security.AccessControl.FileSystemAccessRule...}

*ありの方のAccessはクラス名が出力されているのみである。

NTFSアクセス権が出したかったので、SelectでAccessToString指定してcsvに吐き出すことにした。
元のコマンド内の意味のない連想配列を潰せたので結果オーライということで。

調査コマンドもついでにメモ程度に置いておく

Get-Childitem <調査対象フォルダのルートフォルダ> -recurse | get-acl | select-object @{Label="Name";Expression={split-path $_.Path -NoQualifier}},AccessToString | Export-Csv ./<ファイル名> -NoTypeInformation -Encoding default

参考

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?