Skip to content

Cleanup scripts/cmdlets for Windows machines. Dry run mode before removal

License

Notifications You must be signed in to change notification settings

PowerShellLibrary/WindowsDiskCleanup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WindowsDiskCleanup

PowerShell Gallery License Build Status

PowerShell module for cleaning disk space.

To learn about available cmdlets head to: docs/Public Cmdlets

Usage examples

# Install the module (PowerShell 5.1+ / PowerShell 7+)
Install-Module -Name WindowsDiskCleanup -Scope CurrentUser

# Import the module into the current session
Import-Module WindowsDiskCleanup

# List all commands provided by the module
Get-Command -Module WindowsDiskCleanup

# Dry run - show which IIS log files would be removed older than 100 days
Remove-IISLog -Days 100 -DryRun

# Custom cleanup
$cleanupTargets = @(
    @{ Path = 'C:\Packages\Artifacts'; Days = 900 }
    @{ Path = 'C:\Resources';        Days = 365 }
)

foreach ($target in $cleanupTargets) {
    Write-Host "[CLEANUP][$($target.Path)]"
    $items = Get-ChildItem $target.Path
    $items | Remove-OldItem -Days $target.Days -DryRun
    $items | Remove-OldItem -Days $target.Days
}

Alternatively, you can run complete cleanup with default settings:

cls;.\main.ps1 -DryRun

License

MIT License © Alan Płócieniak

Sponsor this project

  •  

Contributors