"Starting PowerLogRoll @ $(get-date)" | out-file "C:\Log Rollup\rollup-log.txt"
$logs = get-childitem C:\VoiceNet\Log
$year = get-date -f "yyyy"
$month = get-date -f "MM"
$day = get-date -f "dd"
foreach ($file in $logs) {
$file | out-file "C:\Log Rollup\rollup-log.txt" -append
if ($file.CreationTime -lt ($(Get-Date).AddMonths(-1))) {
c:\7z\7za a "c:\log rollup\$month-$day-$year.zip" $file
remove-item -force $file
}
}
$mailmessage.Attachments.Add('C:\Log Rollup\rollup-log.txt')
remove-item -force "C:\Log Rollup\rollup-log.txt"
|