Files
management-scripts/rmm/Start-SystemCleanup.ps1

60 lines
4.2 KiB
PowerShell

#Requires -Version 5.1
# Configure these [string] Dropdown variables in Syncro, each with true/false choices:
# [string]$CleanupReportOnly - true (default: assess all), false (apply enabled only)
# [string]$CleanupSystemTemp - true (default), false
# [string]$CleanupOfficeStaging - true (default), false; uses CleanupTempDays
# [string]$CleanupUserTemp - true (default), false
# [string]$CleanupServiceTemp - true (default), false
# [string]$CleanupCBSArchives - true (default), false
# [string]$CleanupActiveCBSLog - false (default), true
# [string]$CleanupCrashDumps - true (default), false
# [string]$CleanupWERArchives - true (default), false
# [string]$CleanupAutodeskInstallers - false (default), true
# [string]$CleanupRecycleBin - false (default), true
# [string]$CleanupDisableHibernation - false (default), true
# [string]$CleanupCompactSearch - false (default), true
# [string]$CleanupShadowCopies - false (default), true
# [string]$CleanupDownloadedExecutables - false (default), true
# [string]$CleanupDuplicateDownloads - false (default), true
# [string]$CleanupOutlookBackups - false (default), true
# [string]$CleanupITunesBackups - false (default), true
# [string]$CleanupAppleDownloads - false (default), true
# [string]$CleanupBrowserCache - false (default), true
# [string]$CleanupRevitJournals - true (default), false
# [string]$CleanupDeliveryOptimization - false (default), true
# [string]$CleanupComponentStore - false (default), true
# Configure this [string] Dropdown variable in Syncro with these exact choices:
# [string]$CleanupDiskCleanupItems - Standard (default)
# StandardAndUpdates
# StandardUpdatesAndDiagnostics
# All
# None
# None disables native Disk Cleanup. All includes Recycle Bin and recovery data.
# Configure these [string] Runtime variables if you need custom retention values:
# [string]$CleanupTempDays - 7 (default); whole days, 1-3650
# [string]$CleanupDiagnosticDays - 30 (default); whole days, 1-3650
# [string]$CleanupBackupDays - 30 (default); whole days, 1-3650
# Runtime values must be entered each run; omit these variables to use core defaults.
# Uploading this file does not define the variables or their selections in Syncro.
# Syncro injects the variables into the caller scope. Do not assign over them here.
# The main script parses the injected strings and supplies defaults for absent variables.
# Every variable configured in Syncro needs a nonempty value.
# Report-only assesses enabled AND disabled categories in separate report sections.
# Compact output shows totals first and one row per category; no duplicate object dump.
# Hibernation/VSS usage appears in the category MiB column (0.00 if absent).
# Report-only also notes potential component-store savings without estimating them.
# Usage is excluded from savings. Hibernation/VSS remain unassessed on servers.
# Reports do not run DISM analysis; savings from superseded updates are not estimated.
# For full diagnostics, set $VerbosePreference = 'Continue' before Run-Script.
# Verbose output can exceed Syncro's output limit. No new Syncro variables are needed.
# Server-blocked categories are listed without assessment. Native savings may be unknown.
# Server exclusions cannot be overridden by these variables. No reboot is initiated.
# OfficeStaging checks Windows Temp/SystemTemp, execution/profile temp and legacy ProgramData.
# Only recognized, aged installer media is eligible; active deployments and user helpers are protected.
$ErrorActionPreference = 'Stop'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
. $([Scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Tools.ps1')))
# No -Arguments: Run-Script must dot-source the core into this caller's scope.
Run-Script -LivePSScript Start-SystemCleanup