-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.ps1
More file actions
31 lines (25 loc) · 993 Bytes
/
main.ps1
File metadata and controls
31 lines (25 loc) · 993 Bytes
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
param(
[switch]$DryRun
)
Import-Module .\WindowsDiskCleanup\WindowsDiskCleanup.psm1 -Force
$spaceBeforeGB = Get-DiskSpace -SpaceType Free -Unit GB
Write-Host "Free Space Before: $spaceBeforeGB GB" -ForegroundColor Green
$removeCommands = @(
@{ Cmd = "Remove-TempASPNETFile"; Days = 30 },
@{ Cmd = "Remove-IISLog"; Days = 7 },
@{ Cmd = "Remove-ChromiumTempData"; Days = 60 },
@{ Cmd = "Remove-DebugDiagLogs"; Days = 60 }
)
foreach ($command in $removeCommands) {
if ($DryRun) {
write-Host "Executing $($command.Cmd) in Dry Run mode...[days>$($command.Days)]" -ForegroundColor Cyan
& $command.Cmd -Days $command.Days -DryRun
}
else {
& $command.Cmd -Days $command.Days
}
}
$spaceAfterGB = Get-DiskSpace -SpaceType Free -Unit GB
$savingsGB = [math]::Round($spaceAfterGB - $spaceBeforeGB, 2)
Write-Host "Free Space After: $spaceAfterGB GB" -ForegroundColor Green
Write-Host "Disk Space Freed: $savingsGB GB" -ForegroundColor Yellow