Functions/FileSystem/New-ACE.ps1

Function New-ACE
{
    [cmdletbinding()]
    Param
    (
        # User Principal
        [Parameter(Mandatory=$false)]
        [System.Security.Principal.NTAccount]
        $UserPrincipal = [System.Security.Principal.NTAccount]::new("$env:USERDOMAIN\$env:USERNAME"),
        
        # FileSystemRights
        [Parameter(Mandatory=$false)]
        [ValidateSet("FullControl","Read","ReadAndExecute","Write","Modify")]
        [System.Security.AccessControl.FileSystemRights]
        $FileSystemRights = "FullControl",

        # InheritanceFlags
        [Parameter(Mandatory=$false)]
        [ValidateSet("ContainerInherit","ObjectInherit","None")]
        [System.Security.AccessControl.InheritanceFlags]
        $InheritanceFlags = ("ContainerInherit","ObjectInherit"),
        
        # PropagationFlags
        [Parameter(Mandatory=$false)]
        [ValidateSet("InheritOnly","NoPropagateInherit","None")]
        [System.Security.AccessControl.PropagationFlags]
        $PropagationFlags = "None",

        # ACE Type
        [Parameter(Mandatory=$false)]
        [ValidateSet("Allow","Deny")]
        [System.Security.AccessControl.AccessControlType]
        $ACEType = "Allow"
    )
    
    Process
    {
        [System.Security.AccessControl.FileSystemAccessRule]::new($UserPrincipal,$FileSystemRights,$InheritanceFlags,$PropagationFlags,$ACEType)
    }
    
}