Powershell for archiving old data

… should work like this …

$Path = 'F:','G:','H:'
$Daysback = ‘-30’
$CurrentDate = Get-Date
$DatetoDelete = $CurrentDate.AddDays($Daysback)

$Result = Get-ChildItem -Path $Path -Recurse -File |
Where-Object { $.LastWriteTime -lt $DatetoDelete -and $.FullName -notlike ‘F:\Snap Server*’ -and $.FullName -notlike ‘H:\Apps*’ } |
ForEach-Object {
Remove-Item -Path $
.FullName
$NewName = Join-Path -Path $.Directory -ChildPath ($.BaseName + ‘archived’ + $($CurrentDate.ToString(‘dd-MM-yyyy’)) + $.Extension)
New-Item -Path $NewName -ItemType File | Out-Null
[PSCustomObject]@{
Original = $
.FullName
NewItem = $NewName
}
}

$Result | Export-Csv -Path C:\Scripts\RenamedFiles.csv -NoTypeInformation