Skip to content

Instantly share code, notes, and snippets.

@sba923
Last active January 31, 2024 14:49
Show Gist options
  • Save sba923/792b13b3cd8e14eabd92963622a10de0 to your computer and use it in GitHub Desktop.
Save sba923/792b13b3cd8e14eabd92963622a10de0 to your computer and use it in GitHub Desktop.
Helper for "gci ... | ctime x" PowerShell equivalent to "find ... -ctime x"
# this is one of Stéphane BARIZIEN's public domain scripts
# the most recent version can be found at:
# https://gist.github.com/sba923/792b13b3cd8e14eabd92963622a10de0#file-ctime-ps1
[CmdletBinding()]
param (
[Parameter(ValueFromPipeline)]
$Item,
[Parameter(Position=0)][int] $Days
)
Begin
{
#TODO match find's rounding scheme (e.g. for -ctime 0's behavior)
$timeboundary = [datetime]::Now.AddDays($Days)
}
Process {
if ($Item.CreationTime -ge $timeboundary)
{
$Item
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment