Skip to content

Instantly share code, notes, and snippets.

@davidroberts63
Created May 24, 2013 14:36
Show Gist options
  • Save davidroberts63/5643960 to your computer and use it in GitHub Desktop.
Save davidroberts63/5643960 to your computer and use it in GitHub Desktop.
Powershell for setting folder permissions
# This script function should work just fine. If you make modifications and notice that the 'Special Permissions'
# right is checked for the folder/file then see thise link for details on how to resolve that.
#
# http://blog.netnerds.net/2007/07/powershell-set-acl-does-not-appear-to-work/
#
function Set-UserToModifyFolderPermission
{
param(
[string]$fullPath,
[string]$username
)
# Set ACLs on full path for Read | Write | Modify for the username specified.
Write-Host Setting permissions for $username on $fullPath
$acl = Get-Acl $fullPath
$accessrule = New-Object System.Security.AccessControl.FileSystemAccessRule($username, "Modify, Synchronize", "ContainerInherit, ObjectInherit", "None", "Allow")
$acl.AddAccessRule($accessrule)
Set-Acl $fullPath $acl
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment