1

Could someone explain something to me? If I run the command (get-acl .\test.txt) | Select-Object owner, I get

Owner
-----                                                                              
BUILTIN\Administrators   

which is what I was expecting. However, if I run the command (get-acl .\test.txt) | Select-Object Access, I get this:

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

instead of the list of the users/groups who have permissions on that file and what those permissions are. So what am I doing wrong?

1
  • I should probably give some background as to what I am trying to do. There is a certain file on multiple machines that may have different permissions from one machine to the next. I am trying to write a script that will list out the users with access to the file and remove ones that I don't want.
    – Alex
    Apr 14, 2011 at 19:35

2 Answers 2

3

The Access property contains an array. You can expand it without walking a loop:

Get-Acl .\test.txt | Select-Object -ExpandProperty Access
1

Those objects don't have a pretty string conversion when you're trying to print them, so they spit out their object type.

Try something along these lines:

(get-acl .\test.txt) | Select-Object Access | foreach-object { $_.identityreference }
1
  • Thanks! That output was blank but that pointed me in the right direction. The following gives me what I need: (Get-Acl .\test.txt).Getaccessrules($true, $true, [System.Security.Principal.NTAccount]) | Select-Object IdentityReference
    – Alex
    Apr 14, 2011 at 19:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .