Hi All,

A quick powershell script, that if you update the path (either a network machine/server or local) and specifiy location to copy items, it will copy with a date range, current default is 01/01/2017 – 01/01/2019.

Please feel free to copy and update to use accordingly.

##################################
# )___/( #
# {(@)v(@)} #
# {|~~~|} #
# {/^^^} #
# `m-m` #
##################################
# WiseOwl Scripts - Copy files within date ranges function Get-ChildItemModifiedBetween
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true, Position=1)]

[string]

$Path,

[Parameter(Mandatory=$true, Position=2)]
[DateTime] $ModifiedAfter = [DateTime]::ParseExact(“20170101″,”yyyyMMdd”,
[System.Globalization.CultureInfo]::InvariantCulture),
[Parameter(Mandatory=$true, Position=3)]
[DateTime] $ModifiedBefore = [DateTime]::ParseExact(“20190101”,’yyyyMMdd’,
[System.Globalization.CultureInfo]::InvariantCulture),

[Parameter(Mandatory=$false, Position=4)]
[string] $Filter = ‘*’,

[Parameter(Mandatory=$false, Position=5)]
[switch] $Recurse = $false
)

[string]

$fn = $MyInvocation.MyCommand
[string] $stepName = “Begin [$fn]”
[int] $counter = 1
[int] $choice = 0

try
{

$stepName = “[$fn]: Get the matches”
#——————————————–
Write-Verbose $stepName

Get-ChildItem $Path -Recurse: $Recurse -Filter $Filter |
Where-Object {$_.mode -notmatch ‘d’} |
Where-Object {$_.lastwritetime -gt $ModifiedAfter} |
Where-Object {$_.lastwritetime -lt $ModifiedBefore}

}
catch
{
[Exception]$ex = $_.Exception
Write-Error (‘Unable to get files modified within given range! Error in step: [{0}] {1}’ -f `
$stepName, $ex.Message)
}
}
$afterThisDate = [DateTime]::ParseExact(“20170101″,”yyyyMMdd”,
[System.Globalization.CultureInfo]::InvariantCulture)
$beforeThisDate = [DateTime]::ParseExact(“20190101″,”yyyyMMdd”,
[System.Globalization.CultureInfo]::InvariantCulture)

Get-ChildItemModifiedBetween `
-Path ‘MachinetoLookforfiles’ `
-ModifiedAfter $afterThisDate `
-ModifiedBefore $beforeThisDate `
-Recurse: $true |
Copy-Item -Destination “PathtoCopy” -verbose 4>&1 >> “PathtoCopyCopylogs.txt”