#Requires -version 3.0
$ScriptPath = $(Split-Path -Parent $MyInvocation.MyCommand.Definition)
$logdate=Get-Date -Format ddMMyyyy_HHmmss
$Logfile = "E:\Logs\FileProcessing_$logdate.txt"
function LogWrite ([string]$logstring)
Add-content $Logfile -value $logstring
#Zip Files and move to backup folder
I am want to build script which will do housekeeping of logs, archive folder and log activity if any file deleted then mention the file name deleted and similaly if log file deleted then log it what files deleted.
if no files to delete for day then mention in the log file no files to delete.
Backup folder archive data should have 7 years, more then 7 years should do rotation (older files to delete and new files to keep).
Backup folder 7 years files to keep, after that older archive files to delete and newer archive file to keep it.
Log folder 1 years logs to keep, after that older log files to delete and newer log file to keep it.