설명 없음

icaclsresetandbackuptest.ps1 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Define the system folders to back up
  2. $SystemFolders = @( "Users", "Program Files", "Program Files (x86)", "ProgramData", "Windows"
  3. )
  4. # Loop through each system folder
  5. foreach ($Folder in $SystemFolders) { # Check if the folder exists
  6. if (Test-Path -Path $Folder) {
  7. # Save the permissions of the folder to an ACL file
  8. & icacls $Folder /save "$Folder.acl" /t } }
  9. # Define the special folders to back up
  10. $SpecialFolders =@( "WindowsApps", "Program Files\\WindowsApps", "Program Files\\ModifiableWindowsApps", "Windows\\SystemApps", "Windows\\SysWOW64\\config\\systemprofile\\AppData\\Local\\Microsoft\\WindowsApps"
  11. )
  12. # Loop through each special folder
  13. foreach ($Folder in $SpecialFolders) { # Check if the folder exists
  14. if (Test-Path -Path $Folder) {
  15. # Save the permissions of the folder to an ACL file
  16. & icacls $Folder /save "$Folder.acl" /t } }
  17. # Reset the permissions on C:
  18. & icacls C:\\ /reset /t
  19. # Loop through each special folder again
  20. foreach ($Folder in $SpecialFolders) {
  21. # Check if the ACL file exists
  22. if (Test-Path -Path "$Folder.acl") {
  23. # Restore the permissions of the folder from the ACL file
  24. & icacls C:\\ /restore "$Folder.acl"
  25. }
  26. }
  27. # Loop through each special folder again
  28. foreach ($Folder in $SpecialFolders) {
  29. # Check if the ACL file exists
  30. if (Test-Path -Path "$Folder.acl") {
  31. # Restore the permissions of the folder from the ACL file
  32. & icacls C:\\ /restore "$Folder.acl"
  33. }
  34. }

Powered by TurnKey Linux.