$OtherCleanPathsArr = "C:\Temp\*", `
"C:\Windows\Temp\*", `
"C:\`$Recycle.Bin\*", `
"C:\swsetup", `
"C:\Windows\System32\*.tmp", `
"C:\Windows\ServiceProfiles\LocalService\AppData\Local\FontCache-S-*.*", `
"C:\Windows\ServiceProfiles\LocalService\AppData\Local\~FontCache-S-*.*", `
"C:\Windows\*.dmp"
#системные пути для очистки
$InProfilesCleanPathsArr = "\AppData\Local\Temp\*", `
"\Downloads\*", `
"\AppData\Local\*.auc", `
"\AppData\Local\Microsoft\Terminal Server Client\Cache\*", `
"\AppData\Local\Microsoft\Windows\Temporary Internet Files\*", `
"\AppData\Local\Microsoft\Windows\WER\ReportQueue\*", `
"\AppData\Roaming\Microsoft\Word\*", `
"\AppData\Roaming\Microsoft\Excel\*", `
"\AppData\Local\Microsoft\Windows\WebCache\*", `
"\AppData\Local\Microsoft\Windows\Explorer\*.db", `
"\AppData\Local\Microsoft\Office\15.0\Lync\Tracing\*", `
"\AppData\Local\Apps\*", `
"\AppData\Local\Microsoft\Windows Mail\*"
#пути в профилях для очистки
Get-ChildItem -Path \ -Include *.flv, *.mp4, *.wmv, DOMA.DBF, STREET.DBF, KLADR.DBF -Recurse | Remove-Item -Force -ErrorAction SilentlyContinue
#удалили некоторые файлы напрямую
$Profiles = Get-ChildItem (Get-ItemProperty -path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList").ProfilesDirectory `
-Exclude "Администратор", "Administrator", "Setup", "Public", "All Users", "Default User"
#извлекли из реестра местоположение профилей, сформировали список
ForEach ($Path in $OtherCleanPathsArr) {
Remove-Item -Path $Path -Recurse -Force -ErrorAction SilentlyContinue
}
ForEach ($Profile in $Profiles) {
ForEach ($Path in $InProfilesCleanPathsArr) {
Remove-Item -Path $Profile$Path -Recurse -Force -ErrorAction SilentlyContinue
}
$temp = ($Profile.FullName + '\AppData\Local\*.')
#echo $temp
cmd.exe /c "del /Q `"$temp`""
}