Toolkit Extension: Set-Rights($Path) : Grants "Full Control" rights to User Group "Users" on $Path

Topics: Archive - Toolkit Extensions
Nov 20, 2013 at 10:50 PM
# Set Users Security Group to have "Full Control" Rights to a folder.
    Function global:Set-Rights()
        {
            [Cmdletbinding()]
            param
            ( 
                [parameter(Mandatory=$True,
                ValueFromPipeline=$True,
                Position=0)]
                [String[]]$RightsFolder
            )
        
        # Define folder for user rights assignment
            
            $acl = Get-Acl $RightsFolder
            
        # Define ACL rule to apply to the folder
            
            $rule = New-Object System.Security.AccessControl.FileSystemAccessRule("Users","FullControl", "ContainerInherit, ObjectInherit", "None", "Allow")
            $acl.AddAccessRule($rule)
            
        # Apply the rule to the folder
            
            Set-Acl $RightsFolder $acl
            Write-Log "Granting Users Full Control Access to folder $RightsFolder"
        }
Coordinator
Nov 21, 2013 at 4:13 PM
Great job on providing all the extensions :)

One thing you might consider doing is adding a few new parameters. I've picked out a few common ones, based on the FileSystemAccessRule constructor: http://msdn.microsoft.com/en-us/library/sfe70whw(v=vs.110).aspx
    [ValidateNotNullorEmpty()]
    [string] $Path,
    [ValidateNotNullorEmpty()]
    [string] $User,
    [ValidateSet("Delete","Modify", "FullControl", "Read", "Write")] 
    [string] $FileSystemRights = "FullControl",
    [ValidateSet("ContainerInherit","None", "ObjectInherit", "ContainerInherit, ObjectInherit")] 
    [string] $InheritanceFlags = "ContainerInherit, ObjectInherit",
    [ValidateSet("InheritOnly","None", "NoPropagateInherit")] 
    [string] $PropagationFlags = "None",
    [ValidateSet("Allow", "Deny")] 
    [string] $AccessControlType = "Allow"
Hope this helps, Dan