This commit is contained in:
2020-05-22 14:35:46 -04:00
parent c5b16d024c
commit 7907fe891b
15 changed files with 198 additions and 59 deletions
+21 -15
View File
@@ -300,20 +300,25 @@ Function Clean-Files($Items,$SageSetNumber) {
}
## Get the specified cleaning categories and run each one
If ( $All ) {
$User = $true
$System = $true
$WindowsUpdate = $true
$WindowsPreviousVersions = $true
$Invasive = $true
$Misc = $true
}
If ( $User ) { Clean-Files $UserItems $UserItemsSageSetNumber }
If ( $System ) { Clean-Files $SystemItems $SystemItemsSageSetNumber }
If ( $WindowsUpdate ) { Clean-Files $WindowsUpdateItems $WindowsUpdateItemsSageSetNumber }
If ( $WindowsPreviousVersions ) { Clean-Files $WindowsPreviousVersionsItems $WindowsPreviousVersionsItemsSageSetNumber }
If ( $Invasive ) { Clean-Files $InvasiveItems $InvasiveItemsSageSetNumber }
If ( $Misc ) { Clean-Files $MiscItems $MiscItemsSageSetNumber }
## Only run if cleanmgr.exe is present on the target endpoint.
If ( Test-Path "${Env:SYSTEMROOT}\System32\cleanmgr.exe" )
{
If ( $All ) {
$User = $true
$System = $true
$WindowsUpdate = $true
$WindowsPreviousVersions = $true
$Invasive = $true
$Misc = $true
}
If ( $User ) { Clean-Files $UserItems $UserItemsSageSetNumber }
If ( $System ) { Clean-Files $SystemItems $SystemItemsSageSetNumber }
If ( $WindowsUpdate ) { Clean-Files $WindowsUpdateItems $WindowsUpdateItemsSageSetNumber }
If ( $WindowsPreviousVersions ) { Clean-Files $WindowsPreviousVersionsItems $WindowsPreviousVersionsItemsSageSetNumber }
If ( $Invasive ) { Clean-Files $InvasiveItems $InvasiveItemsSageSetNumber }
If ( $Misc ) { Clean-Files $MiscItems $MiscItemsSageSetNumber }
} Else { Write-Output "cleanmgr.exe does not exist!" }
## Function to delete each iTunes backup directory
Function Delete-iTunesBackups($dir) {
@@ -335,7 +340,8 @@ If ( $iTunesBackups ) {
## List of accounts to exclude
$ExcludedUsers = @("Public",
"All Users")
"All Users",
"Administrator")
## Empty array to hold the user directories to clean
$DirectoriesToProcess = @()