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
|
Function Firefox
{
# Définition de la police d'exectution
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
[long]$size = 0
Get-ChildItem -LiteralPath "C:\Users" | Select-Object Name | Export-Csv -Path "C:\temp\utilisateurs.csv" -NoTypeInformation -Force
Import-CSV -Path "C:\temp\utilisateurs.csv" | ForEach-Object{
$Path = "C:\Users\*\AppData\Local\Mozilla\Firefox\Profiles\*.default\cache\"
$size += [long] (Get-ChildItem $Path -Recurse -Force | Where-Object {!$_.PSIsContainer} | Measure-Object -Sum Lenght).Sum
If (Test-Path -Path $Path) {Remove-Item -Path $Path -Recurse -Force -Verbose} Else {}
$Path = "C:\Users\*\AppData\Local\Mozilla\Firefox\Profiles\*.default\cache2\entries\"
$size += [long] (Get-ChildItem $Path -Recurse -Force | Where-Object {!$_.PSIsContainer} | Measure-Object -Sum Lenght).Sum
If (Test-Path -Path $Path) {Remove-Item -Path $Path -Recurse -Force -Verbose} Else {}
$Path = "C:\Users\*\AppData\Local\Mozilla\Firefox\Profiles\*.default\thumbnails\"
$size += [long] (Get-ChildItem $Path -Recurse -Force | Where-Object {!$_.PSIsContainer} | Measure-Object -Sum Lenght).Sum
If (Test-Path -Path $Path) {Remove-Item -Path $Path -Recurse -Force -Verbose} Else {}
$Path = "C:\Users\*\AppData\Local\Mozilla\Firefox\Profiles\*.default\cookies.sqlite"
$size += [long] (Get-ChildItem $Path -Recurse -Force | Where-Object {!$_.PSIsContainer} | Measure-Object -Sum Lenght).Sum
If (Test-Path -Path $Path) {Remove-Item -Path $Path -Recurse -Force -Verbose} Else {}
$Path = "C:\Users\*\AppData\Local\Mozilla\Firefox\Profiles\*.default\webappsstore.sqlite"
$size += [long] (Get-ChildItem $Path -Recurse -Force | Where-Object {!$_.PSIsContainer} | Measure-Object -Sum Lenght).Sum
If (Test-Path -Path $Path) {Remove-Item -Path $Path -Recurse -Force -Verbose} Else {}
$Path = "C:\Users*\AppData\Local\Mozilla\Firefox\Profiles\*.default\chromeappsstore.sqlite"
$size += [long] (Get-ChildItem $Path -Recurse -Force | Where-Object {!$_.PSIsContainer} | Measure-Object -Sum Lenght).Sum
If (Test-Path -Path $Path) {Remove-Item -Path $Path -Recurse -Force -Verbose} Else {}
}
#Action lors de la fin du script.
#Remove-Item "c:\temp\utilisateurs.csv"
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
[System.Windows.Forms.MessageBox]::Show("C'est fait...`n`nEspace gagné $("{0:N0} Mo" -f ($size / 1MB))", "Fin suppression des caches FireFox", 0)
} |