DROTHISM
Get Oldest File in a Directory
Posted by Drothism on Mar 17th, 2009Looking for a quick way to get the oldest file in a directory? Here is a quick and dirty method to do it with PowerShell…
dir f:\archive -recurse| ?{!($_.PSIsContainer)} | sort -property lastwritetime | select -first 1
The ?{!($_.PSIsContainer)} filter will leave sub-directories out of the search.
DROTHISM
Creating PowerShell Exit Codes
Posted by Drothism on Sep 10th, 2008I needed to create a PowerShell script today that would return exit codes. Simply look it up on the internet you say. Well after 30 minutes of searching I did find the trick and thought embedding on here would ensure I could find it next time it was needed…
$host.SetShouldExit($exitcode)
$host is a PowerShell reserved variable so [...]