- start powershell
- set-executionpolicy remotesigned
- Create a script with notepad
get-childitem -Path C:\inetpub\logs\LogFiles -recurse | where-object {$_.lastwritetime -lt (get-date).addDays(-90)} | Foreach-Object { del $_.FullName }
- Save the script @ c:\scripts\del_old_logs.ps1
- start cmd
- run: powershell.exe c:\scripts\del_old_logs.ps1 -noprofile -Noninteractive
- If you get a “child” question press A
- Start task scheduler
- Schedule the task
- program powershell
- c:\scripts\del_old_logs.ps1 -noprofile -Noninteractive
- Run the task wheter user is logged on or not
- Highest privileges not needed