Created
April 18, 2024 08:13
-
-
Save souhaiebtar/66c5b8131a37332a611e73d904db659e to your computer and use it in GitHub Desktop.
[get all permission to folder using powershell] get all permission to folder using powershell #Powershell #Windows #Permissions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ACLPath = "D:\Users\starhoun" | |
$Identity = "Users" | |
$FileSystemRight = "Modify" | |
$Propagation = "0" | |
$inheritance = "3" | |
$RuleType = "Allow" | |
Try { | |
$ACL = Get-Acl -Path $ACLPath | |
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($Identity,$FileSystemRight,$inheritance,$Propagation,$RuleType) | |
$ACL.SetAccessRule($AccessRule) | |
$ACL | Set-Acl -Path $ACLPath | |
} | |
Catch { | |
$ErrorMsg = $_.Exception.Message | |
Write-Host "Set folder permissions error: $ErrorMsg" | |
Exit 421 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment