public/LogFiles/Remove-AuditLogs.ps1
using module '..\..\modules\Config.psm1' using module '..\..\modules\Helper\DateTimeHelper.psm1' function Remove-AuditLogs{ [CmdletBinding()] [Alias('rmalf')] param ([string]$timespan='-20D') $config = [Config]::Load() WRite-Debug "Audit log folder: $($config.auditLogFolder)" $afterDateTime, $beforeDateTime = [DateTimeHelper]::getAfterBefore('', $timespan) $answer = Read-Host -Prompt ($LocalizedData.AuditLogRemovingConfirmationMessage -f $afterDateTime) if ($answer -in ('y', 'yes')){ Get-ChildItem -Path $config.auditLogFolder -Recurse | Where-Object ` { ($_.LastWriteTime -lt $afterDateTime) -and -not $_.PSIsContainer } | ` Remove-Item | Out-Null Write-Host ($LocalizedData.AudigLogsRemovedMessage -f $afterDateTime) -ForegroundColor Green } else { Write-Host ($LocalizedData.AudigLogsRemovedTerminatedMessage -f $afterDateTime) -ForegroundColor Red } } |