Created
August 1, 2012 19:11
-
-
Save kfrancis/3229870 to your computer and use it in GitHub Desktop.
Auto Purge Using PostDeploy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instead of $path, you could just use
cd ..
, since the current directory will be set to the package installation location.