Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

18 Commits

Repository files navigation

WindowsDiskCleanup

PowerShell GalleryLicenseBuild 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 sessionImport-Module WindowsDiskCleanup
# List all commands provided by the moduleGet-Command-Module WindowsDiskCleanup
# Dry run - show which IIS log files would be removed older than 100 daysRemove-IISLog-Days 100-DryRun
# Remove old versions of one package, keeping the latest available versionRemove-NugetPackageVersion-PackageName 'sitecore.cms.core.content'-Days 30-DryRun
# Remove old versions for all packages in C:\nuget (keep latest version for each package)Remove-NugetPackageVersion-NugetFolder 'C:\nuget'-Days 30-DryRun
# Remove old versions for all packages matching a wildcardRemove-NugetPackageVersion-PackageName 'sitecore.cms.*'-NugetFolder 'C:\nuget'-Days 30-DryRun
# Custom cleanup$cleanupTargets=@(
@{ Path='C:\Packages\Artifacts'; Days=900 }
@{ Path='C:\Resources'; Days=365 }
)
foreach ($targetin$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

Run complete cleanup with NuGet package retention:

cls;.\main.ps1 -DryRun -NugetPackages @('sitecore.cms.core.content') -NugetDays 30-NugetFolder 'C:\nuget'

Clean all packages in the NuGet folder (no package list required):

cls;.\main.ps1 -DryRun -NugetDays 30-NugetFolder 'C:\nuget'

License

MIT License © Alan Płócieniak

About

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

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages