Created
September 16, 2021 18:17
-
-
Save dizys/dbba00894bb70b536ac594a6bf91559c to your computer and use it in GitHub Desktop.
Lost edit permissions of files (Access Denied, I know) after reinstalling your Windows? Copy this file to the folder where you want all the subfolders and files to be in your control again. Run it in PowerShell with administrator privileges, then delete or edit them again!
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
foreach ($file in Get-ChildItem . -Recurse) | |
{ | |
$path = Get-Item -LiteralPath $file.FullName | |
$acl = $path.GetAccessControl() | |
$permission = "Everyone","FullControl","Allow" | |
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission | |
$acl.SetAccessRule($rule) | |
$path.SetAccessControl($acl) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment