get-acl information with special format in file

Andreas Sperling 40 Reputation points
2023-11-22T14:19:08.0966667+00:00

Hi, I would like to write the permissions of a directory to a file in a special format. (Fields from left to right)

Example

Get-Acl -Path "\sv008\workgroup\edv" -Filter * | Select-Object -ExpandProperty Access

User's image

Get-Acl -Path "\svgeb008\workgroup\edv" -Filter * | select-object -Property IdentityReference,Filesystemrights,Accesscontroltype

User's image

If I use both

User's image

User's image

And this result i need in an file.
But if I use the following

User's image

I get this information

User's image

What am I doing wrong?

can someone help me and send me some code?

Best regards Andreas

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,548 questions
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 34,346 Reputation points
    2023-11-22T15:58:25.66+00:00

    Something like this?

    $path = "C:\Temp"
    $rpt = "c:\temp\output.txt"
    "Permissions for $path" | out-file $rpt  
    (Get-Acl -Path "c:\temp" -Filter *).access | select-object -Property IdentityReference,Filesystemrights,Accesscontroltype | out-file $rpt -append 
    get-content $rpt
    
    
    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Rich Matheisen 46,806 Reputation points
    2023-11-22T16:08:01.48+00:00

    The "Access" property is an array of objects, each with the type "FileSystemAccessRule". Each FileSystemAccessRule has a set of named properties (AccessControlType, FileSystemRights, IdentityReference, etc).

    I think this is what you set out to achieve:

    Get-Acl -Path "\sv008\workgroup\edv" -Filter * |
    	Select-Object -ExpandProperty Access |
    		Select-Object IdentityReference,Filesystemrights,Accesscontroltype |
    			Out-File c:\temp\output.txt
    			
    
    1 person found this answer helpful.

  2. Andreas Sperling 40 Reputation points
    2023-11-22T16:27:24.2533333+00:00

    For my purpose, Rich's code is perfect.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.