Last active
April 25, 2024 20:11
-
-
Save 0x11DFE/da817cc74e4cbf6532bd108391fc6ba4 to your computer and use it in GitHub Desktop.
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
## | |
# - @T3SL4 | |
# This PowerShell script is used to manage the permissions of a folder for the current user. | |
# It first prompts the user to input the folder path and then asks whether they want to do. | |
# This can be useful for protecting sensitive folders from accidental modification or deletion. | |
## | |
$folderPath = Read-Host -Prompt 'Input your folder path'; $username = whoami; $action = Read-Host -Prompt "(1) Block current-user from deleting, modifying, or renaming folder.`n(2) Restore current-user access?`nEnter the number"; if ($action -eq 1) { takeown /F $folderPath /A /R /D Y; icacls $folderPath /inheritance:r; icacls $folderPath /grant:r $username':(RX)' /T; icacls $folderPath /deny $username':(WD,AD,DC,WDAC,WO,WD)'; attrib +r $folderPath /S /D } else { icacls $folderPath /grant:r $username':(M)' /T; attrib -r $folderPath /S /D } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment