none
Auto Purge perfmon Logs RRS feed

  • Question

  • We have perfmon running on a 24/7 basis and we need it to automatically purge old ones after a certain amount of time so the disk doesn't get full. Is there a way to do this without stopping and starting it again?


    Tuesday, May 24, 2016 2:46 PM

All replies

  • I wrote a script to do this.


    ##Brendan Cowie June 2016

    ## get computer name
    $cname = $env:computername

    #take the current year month and day, subtract 2 weeks and pass it to a variable 
    $year = Get-Date (Get-Date).AddDays(-14) -format "yyyy"
    $month = Get-Date (Get-Date).AddDays(-14) -format "MM"
    $day = Get-Date (Get-Date).AddDays(-14) -format "dd"


    #current data for loggin purposes
    $date = Get-Date -format "yyyyMMdd"


    ## remove the logs that are 14 days old only 

    remove-item C:\Perf\$cname"_"$year$month$day"*" -recurse -verbose 4> C:\Perf\$date.log

     


    Tuesday, June 14, 2016 6:47 PM