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