public/Utils/Remove-LogFiles.ps1
using namespace System.Management.Automation using module '..\..\modules\Enums.psm1' using module '..\..\modules\Helper\DateTimeHelper.psm1' using module '..\..\modules\Session.psd1' function Remove-LogFiles{ [CmdletBinding()] [Alias('rmalf')] param ([string]$timespan='-30D') $afterDateTime, $beforeDateTime = [DateTimeHelper]::getAfterBefore('', $timespan) Get-ChildItem -Path [Config].instance.auditFolder -Recurse | Where-Object ` { ($_.LastWriteTime -lt $beforeDateTime) -and ($_.LastWriteTime -gt $afterDateTime) -and -not $_.PSIsContainer } | ` Remove-Item | Out-Null Write-Host 'Logs removed' -ForegroundColor Green } |