Powershell 7 get Aduit settings on file/folder

Belan Marek 56 Reputation points
2022-05-04T08:01:02.157+00:00

Hi all please how can i get audit setting of file / folder by powershell 7?
On PS 5 is method GetAccessControl('Access, Audit').AreAuditRulesProtected

I need to check if audit settings has enabled inheritance.
198689-image.png

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 47,901 Reputation points
    2022-05-05T18:24:20.13+00:00

    Why not use a PowerShell cmdlet to get that information?

    Get-ACL -Path <path-to-file> -Audit

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Limitless Technology 39,921 Reputation points
    2022-05-05T14:37:40.823+00:00

    Hi @Belan Marek

    Kindly run following query in administrator mode.

     $path = "C:\Users\ravi2_000\OneDrive\Desktop\Loan"  
     $f = Get-Item $path  
     $f.GetAccessControl()  
     $f.GetAccessControl('Access, Audit').AreAuditRulesProtected  
    

    Result would be as below,

    Path Owner / Access
    5CD4392B17\ravi2_000 NT AUTHORITY\SYSTEM Allow FullControl...
    False

    Here is a helpful page with information about Windows PowerShell

    https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/powershell

    --------------

    --If the reply is helpful, please Upvote and Accept as answer.--


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.