Created
February 13, 2019 17:37
-
-
Save Graham-Beer/2f306f80b47f1deb83b37f39c7973e18 to your computer and use it in GitHub Desktop.
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
function Invoke-FileArchive { | |
param ( | |
[Parameter( | |
Mandatory, | |
Position = 0, | |
ValueFromPipeline, | |
ValueFromPipelineByPropertyName | |
)] | |
[Alias('FullName')] | |
[System.IO.FileSystemInfo[]] $Path, | |
[Parameter(Mandatory, Position = 1)] | |
[String] $Destination, | |
[Parameter(Position = 2)] | |
[TimeSpan] $OlderThan = '1.0:0:0' | |
) | |
process { | |
foreach ($file in $Path) { | |
if ($file -is [System.IO.FileInfo]) { | |
$file | | |
Where-Object { | |
$_.LastWriteTime -lt (Get-Date).Add($OlderThan.Negate()) | |
} | Move-Item -Destination $Destination | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment