Skip to content

Instantly share code, notes, and snippets.

@kfrancis
Created August 1, 2012 19:11
Show Gist options
  • Save kfrancis/3229870 to your computer and use it in GitHub Desktop.
Save kfrancis/3229870 to your computer and use it in GitHub Desktop.
Auto Purge Using PostDeploy
cd .. # Since PostDeploy is in the latest deployed version directory, just back out one level. Thanks Paul!
$path = Get-Location
$folders = Get-ChildItem -Path $path -Recurse | Where-Object {$_.PsIsContainer}
$keep = 3
if ($folders.Count -gt $keep) {
$folders |Sort-Object CreationTime |Select-Object -First ($folders.Count - $keep)| Remove-Item -Force
}
@PaulStovell
Copy link

Instead of $path, you could just use cd .., since the current directory will be set to the package installation location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment