How to delete Sharepoint Diagnostic log older than 5 months

Hello , 
How can I automate Sharepoint log deletion older than 5 months using powershell or C# code ?

I ran across this code (frankly forgot where) a few years ago, originally to delete IIS logs, but I use if for everything.  It simply goes through each item in a folder and deletes by date.  I save the code below to a ps script, then call it with
a batch file and schedule a task to run the batch file (reasoning is it is easier to schedule a task to run as a .bat file than .ps1.  Don't forget about changing the execution policy if you decide to use it on non-SharePoint servers as well.
get-childitem -Path C:\inetpub\logs\LogFiles -recurse |
where-object {$_.lastwritetime -lt (get-date).addDays(-7)} |
Foreach-Object { del $_.FullName }

Similar Messages

  • I accidentally deleted the tab marked "older than 6 months" on the history for firefox how do I fix it?

    I was trying to view the history on FireFox and I accidentally deleted the tab for "older than 6 months" how do I get it back? or will it come back on its own? someone please help.

    Additionally If you have Sync or any other form of backup, you can try to restore the history. You can also try to restore an older '''places.sqlite''' in the Firefox profile directory: '''Help''' ('''Alt''' + '''H''') > '''Troubleshooting Info''' > '''Show Folder'''.

  • How to delete daily all idocs older than one year

    Hello
    I wander how to delete daily all idocs older than one year. I guess with an job(but how to create it)

    Hi
    Check this [Link|https://ecohub.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/17c435df-0901-0010-72a7-b9dcd271213d]
    Just give a search in SDN you could find lot of doucments releated to archiving of idocs
    Regards
    Uday

  • Firefox is slowly deleted my browser history older than 6 months. How do I keep history forever?

    I just noticed that my browser history older than 6 months is slowly being deleted day by day. How do I prevent this from happening? This has only started happening recently. I have my settings as "Remember history". I want to keep all my history forever. Are there any configurations I can make to achieve this?
    Thanks for your time.

    Firefox automatically calculates how many pages to keep without affecting performance and saves that value in the transient_max_pages pref.
    You can create a max_pages pref to override that current maximum, but it is better to leave those prefs at their default.
    You can see the current value via the read-only pref places.history.expiration.transient_max_pages on the about:config page.

  • How to delete Folders and Files older than 10 day ?

    If I use this below command, I am able to delete only the files and files in sub-folders older than 10 day,
    forfiles /p "D:\Testing\Sample" /s /d -10 /c "cmd /c del /s /q @file"
    Please help...
    Thanks

    Hello Raman459,
    please see this blog entry:
    http://elderec.org/2012/02/scripting-delete-files-and-folders-older-than-x-days/
    Your command is ok for files, for folders you need to do another command:
     forfiles -p "D:\Testing\Sample" -d -10 -c "cmd /c IF @isdir == TRUE rd /S /Q @path"
    If this post solved your question, please mark as an answer, or if it helped your quest, please vote as helpful. Thank you.
    Thank you,
    F. Schubert
    System Administrator
    MCP | Microsoft Certified Professional
    MCTS 70-640 | Microsoft Certified Technology Specialist: Windows Server 2008 Active Directory, Configuration
    MCTS 70-642 | Microsoft Certified Technology Specialist: Windows Server 2008 Network Infrastructure, Configuration
    MCTS 70-643 | Microsoft Certified Technology Specialist: Windows Server 2008 Applications Infrastructure, Configuring
    MCTS 70-680 | Microsoft Certified Technology Specialist: Windows 7, Configuration

  • Deleting backups older than a month

    Hi all,
    I'm trying to delete backups that are older than a month. I've performed the following steps.
    1. Click on time machine
    2. Navigate to a month ago
    3. Navigate to "Macintosh HD" and select all items
    4. Click on the gears the "Delete all backups .."
    This delete all backups, even my current ones. How can I delete just "old" versions from a snapshot in time (say x) back to the beginning of backups and keep everything with time > x?
    Thanks,
    Todd

    +That won't screw up the database will it?+
    Probably. Time Machine uses hard links to keep track of its previously backed up files. You can read how Time Machine uses hard links in this Ars Technica review.
    http://arstechnica.com/reviews/os/mac-os-x-10-5.ars/14
    To make sure you keep the hard links intact launch the Time Machine browser from the dock. Click on your hard drive in the sidebar. Don't select any folders or files in the window. Use the white ladder lines on the right to navigate to the backup you wish to delete. Click on the button with the gear and select Delete Backup.

  • How to sync calendar data older than 1 month?

    How to sync data from calendar older than 1 month? (from computer to phone) Impossible to get my data from beginning of november on calendar on Iphone. What did I miss?

    If you are syncing calendar events direct with Outlook via the iTunes sync process, there is a setting for this under the Info tab for your iPhone sync preferences with iTunes below the sync calendars section.

  • How can I set up a rule to delete all messages older than 6 months left in Apple Mail's main inbox?

    How can I set up a rule to delete all messages older than 6 months left in Apple Mail's main inbox?
    I have created other rules to move some of my daily messages into specific folders and I don't wish to auto-delete those.
    Just the general stuff that keeps piling up in my me.com main email box.  Mail such as FB announcements and other low priority stuff I want to look at before deleting but don't want to keep longer than a week or month.
    TIA
    thokitts

    Thanks, but I am looking for a more automated solution than hand marking emails as junk. I might as well move them to the trash myself.
    Again, these are emails I want to receive and quickly read, but not keep longer than a week or month or so. By setting a rule to toss any older than 30 days back then my Mail program (and thus my hard drive) won't be wasting so much space. For example, currently I have over 6000 read messages, with their attachments, in my main email box. I'd rather not have to physically attend to sorting the one I don't want out.
    The one I do keep for other reasons get moved into other folders.
    It seems this should be possible.
    thokitts

  • TS3899 I upgraded to iOS 7 and I lost emails that were in my inbox - I used to see all emails that I did not delete, now I only have emails from the past month - how can I get the old, undeleted emails back? Or, at least, show email older than one month o

    I upgraded to iOS 7 and I lost emails that were in my inbox - I used to see all emails that I did not delete, now I only have emails from the past month - how can I get the old, undeleted emails back? Or, at least, show email older than one month old?

    I upgraded to iOS 7 and I lost emails that were in my inbox - I used to see all emails that I did not delete, now I only have emails from the past month - how can I get the old, undeleted emails back? Or, at least, show email older than one month old?

  • [journalctl] cannot find log older than actual boot

    Hi,
    my system just crashed, so i runned "sudo journalctl", but there is no log older than THIS session...
    it is the way journalctl works, or something really bad is going on?
    how i'm supposed to find what whent wrong? /var/log seems unused since 28 august, when i've installed a full systemd
    cheers

    That's the default. You can change it by creating the appropriate place for a permanent log and/or you can tell it to use syslog-ng and modify that service to use systemd's logging.
    This is all explained in the wiki - see https://wiki.archlinux.org/index.php/Sy … md_Journal.
    EDIT: beaten to it.
    Last edited by cfr (2012-10-04 22:51:59)

  • *HOW TO DELETE THE ARCHIVE LOGS ON THE STANDBY*

    HOW TO DELETE THE ARCHIVE LOGS ON THE STANDBY
    I have set the RMAN CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY; on my physical standby server.
    My archivelog files are not deleted on standby.
    I have set the CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default on the Primary server.
    I've checked the archivelogs with the FRA and they are not beign deleted on the STANDBY. Do I have to do something for the configuation to take effect? Like run a RMAN backup?
    I've done a lot ofresearch and i'm getting mixed answers. Please help. Thanks in advanced.
    J

    Setting the Policy will not delete the Archive logs on the Standby. ( I found a thread where the Data Guard product manager says "The deletion policy on both sides will do what you want" ). However I still
    like to clean them off with RMAN.
    I would use RMAN to delete them so that it can use that Policy are you are protected in case of Gap, transport issue etc.
    There are many ways to do this. You can simply run RMAN and have it clean out the Archive.
    Example :
    #!/bin/bash
    # Name: db_rman_arch_standby.sh
    # Purpose: Database rman backup
    # Usage : db_rman_arch_standby <DBNAME>
    if [ "$1" ]
    then DBNAME=$1
    else
    echo "basename $0 : Syntax error : use . db_rman_full <DBNAME> "
    exit 1
    fi
    . /u01/app/oracle/dba_tool/env/${DBNAME}.env
    echo ${DBNAME}
    MAILHEADER="Archive_cleanup_on_STANDBY_${DBNAME}"
    echo "Starting RMAN..."
    $ORACLE_HOME/bin/rman target / catalog <user>/<password>@<catalog> << EOF
    delete noprompt ARCHIVELOG UNTIL TIME 'SYSDATE-8';
    exit
    EOF
    echo `date`
    echo
    echo 'End of archive cleanup on STANDBY'
    mailx -s ${MAILHEADER} $MAILTO < /tmp/rmandbarchstandby.out
    # End of ScriptThis uses ( calls an ENV) so the crontab has an environment.
    Example ( STANDBY.env )
    ORACLE_BASE=/u01/app/oracle
    ULIMIT=unlimited
    ORACLE_SID=STANDBY
    ORACLE_HOME=$ORACLE_BASE/product/11.2.0.2
    ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
    LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
    LIBPATH=$LD_LIBRARY_PATH:/usr/lib
    TNS_ADMIN=$ORACLE_HOME/network/admin
    PATH=$ORACLE_HOME/bin:$ORACLE_BASE/dba_tool/bin:/bin:/usr/bin:/usr/ccs/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:/usr/lbin:/GNU/bin/make:/u01/app/oracle/dba_tool/bin:/home/oracle/utils/SCRIPTS:/usr/local/bin:.
    #export TERM=linux=80x25 wrong wrong wrong wrong wrong
    export TERM=vt100
    export ORACLE_BASE ORACLE_SID ORACLE_TERM ULIMIT
    export ORACLE_HOME
    export LIBPATH LD_LIBRARY_PATH ORA_NLS33
    export TNS_ADMIN
    export PATH
    export MAILTO=?? your email hereNote use the env command in Unix to get you settings.
    There are probably ten other/better ways to do this, but this works.
    other options ( you decide )
    Configure RMAN to purge archivelogs after applied on standby [ID 728053.1]
    http://www.oracle.com/technetwork/database/features/availability/rman-dataguard-10g-wp-1-129486.pdf
    Maintenance Of Archivelogs On Standby Databases [ID 464668.1]
    Tip I don't care myself but in some of the other forums people seem to mind if you use all caps in the subject. They say it shouting. My take is if somebody is shouting at me I'm probably going to just move away.
    Best Regards
    mseberg
    Edited by: mseberg on May 8, 2012 11:53 AM
    Edited by: mseberg on May 8, 2012 11:56 AM

  • HT3275 I've 1.85TB empty space on my time Machine, but it only backs up to the beginning of the previous month. it should have weekly back-ups for every month before that. Any ideas why it deletes stuff older than a month?

    I've 1.85TB empty space on my Time Machine, but it only retains back-ups to the beginning of the previous month. I should be able to access weekly back-ups for every month before that until the disk is full. Any ideas why it deletes stuff older than a month?
    Thanks, Rigby.

    If you are using Ethernet to connect your Mac to the Time Capsule, are you allowing at least 2-3 minutes for Time Machine to fully load when you open the application to see your backups?
    If you are using wireless to connect, you may need to allow 8-10 minutes or longer for everything to fully load, depending on the speed of your wireless connection.
    If you see only white time "bars" on the timeline at the right of the screen, you are seeing temporary backups. Permanent backups are displayed with purple "bars".

  • Mail sent older than one month and half deleted

    Hello,
    all the message older than one month and a half I have sent have have been deleted or are not displayed either on my MacBook Air with the e-mail application or with Safari connecting me directly with my account on ICloud web site.
    By side, the message I have put in archive folder or that are in my inbox are still there even if they are older than one month and a half.
    Do you have any idea to solve this issue ?
    Thank you very much.

    Check your sent folder settings at mail > preferences > accounts > iCloud > mailbox behaviours.

  • How to import photos older than 18 months from ipad

    How do I import Photos from my ipad to my computer that are older than 18 months old?

    Hi Terence,
    thanks for your reply.
    i've scrolled, oh i've scrolled, I've gone through every individual picture that is displayed in the photos option, and through the events option and while it's true there are photos past 18 months, there are lots of photos that used to be in my iPhoto library that are now missing in action. 
    I also tried the Smart Albums, thanks for the suggestion, and nothing came up that was older than 2009.  I definitely have photos older than that and desperately need them.  Thoughts?

  • When creating a photo book, how can one import photos older than 12 months?

    I am trying to create a photo book (I'm using iPhoto 11).  For my project, I'm trying to access photos older than 12 months, but that is not an option in the photo library at the right of the screen. 
    I have tried to click and drag the old photos into my project event.  They show up fine in "photos" but do not show up in the photo library!
    I have also found that photos downloaded from a CD do not show up in the photo library either.
    Anyone have any thoughts?

    You can not - they are soreted by date
    --  the only solution I have seen is to put them in an album sorted the way you and and then use the batch cnage command to redate them with a small invrement between so a data sort matches your desired sort  --  I personally do not want to redate a bunch of my photos nor do i want  to have to go through and un-re- date a bunch
    suggest a change to Apple - iPhoto menu ==> provide iPhoto feedback
    LN

Maybe you are looking for

  • Multi room viewing causes recordings and dvr functions to fail

    Configuration:  HD dvr's in both living room and bedroom. Watch a show in my living room from the bedroom dvr.  While I am viewing this a new recording starts on the living room dvr.  When I finish watching the bedrooom show and while the living room

  • How to bluetooth from PC

    Hi. I'm struglling to Bluetooth from my PC to my Iphone 4. what Hardrive do I need to complete this action. Any tips on how to get it or what to do would be Appreciated. Thanks

  • Upto previous period data

    Hi how to get upto previous month data if select aug-11 then i get upto jul-11 data for the aug-11 how to do this i have gldate,startdate,enddate

  • ITunes does not open or launch

    My iTunes will not open. If I click on a shortcut it tells me "This action is only allowed for products that are currently installed." So I tried to uninstall my iTunes but it won't let me. It says that "The feature you are trying to use is in on a n

  • Voice recordings to Removable Dr

    Hi, I recieved my Zen Micro (6gb) last thursday and so far I am very pleased with it, touch pad is great Anyway heres a problem, I need to do a voice recorded interview as part of primary research for a course and I want to use my Zen Micro but I kno