-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRESET_PERM_FOLDERS_ V080.ps1
More file actions
56 lines (45 loc) · 2.17 KB
/
RESET_PERM_FOLDERS_ V080.ps1
File metadata and controls
56 lines (45 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Add-Type -AssemblyName Microsoft.VisualBasic
Add-Type -AssemblyName PresentationFramework
# 📁 Wybór folderów przez GUI
$selectedFolders = [Microsoft.VisualBasic.Interaction]::InputBox(
"Podaj ścieżkę folderu lub folderów oddzielonych znakiem średnika, by przywrócić podstawowe uprawnienia dostępu",
"Wpisz ścieżkę do folderu/folderów",
""
)
# Rozdziel na listę
$folderList = $selectedFolders -split ";" | Where-Object { $_.Trim() -ne "" }
# Jeśli nic nie podano
if ($folderList.Count -eq 0) {
Write-Host "❌ Nie podano żadnych folderów. Zakończono." -ForegroundColor Red
return
}
# 📋 Potwierdzenie
Write-Host "`n📂 Foldery do przywrócenia podstawowych uprawnień dostępu:"
$folderList | ForEach-Object { Write-Host " - $_" }
$confirmation = Read-Host "`n❓ Czy na pewno rozpocząć przywracanie uprawnień dla wybranych folderów? (T/Y = Tak, N = Nie)"
if ($confirmation -notin @("T", "t", "Y", "y")) {
Write-Host "🔁 Możesz teraz ponownie uruchomić skrypt i podać inne foldery." -ForegroundColor Cyan
return
}
# 📄 Plik logu
$logPath = "$env:USERPROFILE\icacls_log_$(Get-Date -Format 'yyyyMMdd_HHmmss').txt"
New-Item -Path $logPath -ItemType File -Force | Out-Null
# 🔄 Przywracanie uprawnień dostępu...
foreach ($folder in $folderList) {
Write-Host "`n🔧 Przetwarzanie: $folder"
Add-Content -Path $logPath -Value "`n=== Folder: $folder ==="
$items = Get-ChildItem -Path $folder -Recurse -Force -ErrorAction SilentlyContinue |
Where-Object { -not ($_.Attributes -match "ReparsePoint") }
# Dodaj folder główny
$items += Get-Item -Path $folder
foreach ($item in $items) {
try {
icacls $item.FullName /reset /C /Q /L | Out-Null
Add-Content -Path $logPath -Value "✔️ OK: $($item.FullName)"
} catch {
Add-Content -Path $logPath -Value "❌ Błąd: $($item.FullName)"
}
}
}
Write-Host "`n✅ Zakończono pomyślnie. Plik LOG z przebiegiem operacji zapisano do: $logPath" -ForegroundColor Green
[System.Windows.MessageBox]::Show("Wciśnij OK by zakończyć działanie skryptu.")