Delete Logs Powershell
redhcp

redhcp @redhcp

About: ☕Coffee - 💻Tech - 🏍Travel Lover - 🕊@Th3Ces4r

Location:
127.0.0.1
Joined:
Nov 11, 2020

Delete Logs Powershell

Publish Date: Jan 10 '22
3 0

Powershell script for delete records older than the number of days established.

$Path = "c:\inetpub\logs\LogFiles"
$Daysback = "-60"
$CurrentDate = Get-Date
$DatetoDelete = $CurrentDate.AddDays($Daysback)
Get-ChildItem $Path -Recurse -Force | Where-Object { $_.LastWriteTime -lt $DatetoDelete } | Remove-Item

Enter fullscreen mode Exit fullscreen mode

Comments 0 total

    Add comment