Automatically Delete Calendar Events Older Than a Day old.

I am trying to have SharePoint automatically delete any events that are a day old.  I have a vacation calendar that needs to remove any older dates and only keep up to date with the new ones.  I have tried to search for the solution and cant
find anything.  I don't want to filter the events it needs to be removed.

function Calendarcleanup() 
#Get Site
$Web=Get-SPWeb  "Site url" 
Write-Host $Web.url 
#Get the Target Calendar List
$list = $web.Lists["XXXX"] 
Write-host $list.title 
#Query the list items based on your requirement
$query=new-object Microsoft.SharePoint.SPQuery 
$query.Query='<Where>
<Lt>
     <FieldRef Name="Created"/><Value Type="DateTime">Today</Value>
</Lt>
</Where>' 
$query.RowLimit = $list.Itemcount 
#Get the itemcollection for processing
$Items=$list.GetItems($query) 
Write-Host $Items.count 
#Loop through the items and delete them
foreach($item in $Items) 
Write-Host "Deleting" $item.Title 
#Deleting items
$list.GetItemById($item.ID).Delete() 
Write-Host "Deleted" $item.Title 
Calendarcleanup

Similar Messages

  • Why spotlight is not able to perform searches on iCal events older than 365 days?

    why spotlight is not able to perform searches on iCal events older than 365 days? I really do not understand why if iCal can sync all events, even the very old, the spotlight will not be able to search on events older than 365 days; why? is absurd; let's say I want to search for a person contained in an old appointment: iCal in your Mac with a few key words, I find it right away, but this important feature on the iPhone is locked; we have in our pockets phones are very sophisticated, but it does not manage to make things really trivial.

    Submit your feedback directly to Apple using the appropriate link on the Feedback page:
    http://www.apple.com/feedback

  • Powershell Command to permanently delete items in ALL users Deleted Items folder older than X days.

    Does anyone know a powershell command that can be run on Exchange 2010 SP1 that will permanently delete mail in the deleted items folder older than X days for ALL users in a specific database? This should include any user created subfolders in deleted items
    also.
    I know that seems bizarre to have user created subfolders in deleted items but we have found that users have discovered that if they create subfolders then their deleted items dont get purged at the regular retention period time.
    Thank You.

    Hi,
    For Exchange 2010 SP1, we can use search-mailbox and new-mailboxexportrequest to delete message in certain folder.
    Understanding Exchange Search
    http://technet.microsoft.com/en-us/library/bb232132.aspx
    Xiu Zhang
    TechNet Community Support

  • Why does my iCal delete all events older than a year? Is this a synch issue? I'm running Snow Leopard.

    Why does my iCal delete all events older than a year? Is this a syn issue? I'm running Snow Leopard.

    this has already been answered.
    please ignore my question.

  • TS2481 All of my calendar history older than 30 days has disappeared from my iphone5.  I have not synced it with my computer.  It just suddenly disappeared.  Is there any way to get it back?

    All of my calendar history older than 30 days has disappeared from my iphone 4S.  I did not perform a sync with my computer-it literally just disappeared!  Is there any way to get it back?

    Unfortunatly for me I did not, do you think there might be any other way? Maybe by accesing it directly through direct USB contact and not through iTunes?

  • ICM 7.5.9 deletes DD records older than 15 days

    Hi guys,
    I have a strange thing happening with our ICM 7.5.9 installation...
    The Dialer Detail table for the Outbound Option deletes the records older than 15 days...
    I checked the purge jobs and they all reference registry keys which have a value of 1000 + days...
    This only happens with the DD table... all the other historical tables retain the data as set in the reg keys...
    I have no clue where to start troubleshooting this... anyhelp is wellcome.

    Below is the link to check the logs if the purge cycle on HDS was successful.
    http://www.cisco.com/en/US/products/sw/custcosw/ps1001/products_qanda_item09186a008020f1e2.shtmlSo turn on the EMSTraceMask to ffff for rpl process on the AW and check the logs around mid night it should give you some clue.
    Use the ICMDBA to check the size of your hds db if it is 80%+ full it will start purging
    the tables.
    eg trace would look like,
    09:52:39 dis-rpl Trace: 80% of the available free space is used in
    XX_hds database.
    09:56:39 dis-rpl Trace: 80% of the available free space is used in
    XX_hds database.
    If you see similar messages expand the HDS db using the below link
    http://www.cisco.com/en/US/products/sw/custcosw/ps1001/products_tech_note09186a0080094927.shtml
    Hope this helps.
    Shirish

  • ICal server not sending events older than 10 days

    Have just discovered an issue with our iCal Server that I hope someone can help me resolve. It seems that sometime in the last few days, or past week. the iCal Server (running on a Snow Leopard Server 10.6.8 setup) has stopped sending out any events older than 10 or so days for 6 of the 7 calendar calDAV accounts that we all subscribe too. All future events on each calendar appear to be visible. The situation is consistent across of all of our Desktop's, MacBook Pro's and iPhone's so it is not localized to any single machine. It is also consistent when I subscribed through a third party calnedar application (BusyCal).
    I have gone into the ~/Library/CalendarServer/Documents and although I could not access the folders directly, I did copy the folder and its contents to another hard drive where I was able to view what was inside. It appears that all of the individual event .ics files for each account are in their respective subfolders, but they are not being served out to the subscribers.
    Any ideas on how to get these older events to become visible again would be very much appreciated. I am not very well versed on this type of thing and am learning on the fly.
    Shawn

    I'm having this same issue and I'm really ticked off.
    When I upgraded today, I received a message saying that because I had so many events in the past that it would take longer to upgrade everything. It said that all my current and future events had been updated, but the past events would be available in 1 hour. Well, it's been a lot of 1 hours since then and nothing. All my events have been deleted from my MacPro, MacBook Pros, and iPhone. I'm holding out hope for them to reappear in the morning.
    I know this isn't part of this thread, but I thought I'd throw it out anyway. Why are my subscribed calendars NOT visible online. Apple made an announcement in the past celebrating the ability to view subscribed calendars online when they once could not. Now with a new ADVANCEMENT, we've regressed and I cannot view subscribed calendars online. I hate to break it to Apple, but I use these subscribed calendars in my scheduling and planning, too. I still need to see them online just as I do on my computer and phone. So with all the updating and wonderful features, the lack of this one makes MobileMe online calendars useless to me and others.
    One step forward, two steps back.

  • How to keep iCal events older than 90 days?

    We use one of our iCal calendars for business, and we need to refer back to client appointments that occurred several months in the past.  However, despite unchecking all the "Delete events" options in Prefs, any appointment older than 90+ days is gone.  This is extremely annoying for all concerned.  Is there a fix, or do we have to use something like Google calendar and link to it?  I'm looking for a simple solution for everyone in the office.

    I am having the same issue in a slightly different way.
    Have a main calendar server I connect to at work and iCal syncs via CalDAV.
    Nothing over about 90 days is getting pulled down even after deleting the calendar.
    I am not the only one at work with a Mac that faces this issue.
    There are 3 other threads with similar topics:
    http://discussions.apple.com/thread.jspa?threadID=2658904
    http://discussions.apple.com/thread.jspa?threadID=2614205&start=15&tstart=0
    http://discussions.apple.com/message.jspa?messageID=12495527#12495527
    Going to try some of the suggestions there.

  • Calendar search not finding calendar events older than a year.

    Calendar search cannot find events older than a year.
    neither does spotlight search.
    iphone 4s 16GB ios version 7.1.2
    ipad 32GB with retina (purchased on 2012) ios version 7.1.2
    Does anybody has the same issue?
    Calendar events over one year old are not found when searched on iOS. Neither on the iPhone nor the iPad. Although they are found on a mac running mavericks calendar app.
    All events are displayed when going directly to the month and viewing all the events of each day, but she search feature, the one accessed through the little magnifier, simply cannot find any event older than a year.
    I have multiple events in my calendar and I tested them and the last I can find is within 365 days of today. after that events cannot be found.
    steps to reproduce:
    1. go into the calendar app on the iPhone and add an event but use a date date 13 months older than the current date. Save the event.
    2. verify the even is created by looking at the day of the event
    3. on the top right corner of the calendar app select the magnifying glass and try to search the event by typing any word you used on the title of the event just created
    4. search result will display No Results
    5. exit the calendar and access spotlight search on the home screen by using the "pull down" gesture from an area outside of the dock, including the top row of app icons. Type any word you used on the title of the event just created
    6. search result will not display the event
    Thanks

    this has already been answered.
    please ignore my question.

  • "A script that will delete perfstat snapshots older than 90 days with SPPURGE..."

    Hello to all my fine Oracle related friends...We are all one large extended Family...
    I want to create a script that will execute SPPURGE on Perfstat for snapshots that are older than 90 days.
    Now, I have Grid 12c Cloud Control up and running for all the Databases that we have...
    Should I use Grid 12c to execute the SPPURGE and just pass the parameters in like that?
    Or should I go "Old School" and make a Shell Script and schedule it in the crontab?
    What would you guys do?
    I want implement this for 41 "Standard Edition" Databases....some are "Data Guard".....
    Thanks,
    Xevv.

    Xevv Bellringer wrote:
    Hi Ed,
    I tried executing this manually and it's not deleting the snapshots at all.
    begin
    statspack.purge(trunc(sysdate-90),true);
    end;
    I even let it for an entire day and then altered the code like this...But when I execute it, it doesn't deleted the data..
    begin
    statspack.purge(trunc(sysdate-1),true);
    end;
    When I do a select sysdate -1 from dual; it gives the correct date?
    Could there be a "NLS Setting" some where causing this?
    How do you determine that it is not deleteding data?  (please show evidence)
    How, and how often, are you collecting a statspack snapshot?  (please show evidence)

  • How to delete calendar entries older than 2 years without recurring events

    The calendar files get larger and larger and slower and slower
    it would be nice to get rid of old entries
    recurring events that are active for less than 2 years shold NOT be removed

    I wanted that same function for myself, but could not find anything out there to do it. Since I am a professional programmer, I wrote a program in Python to do the job.
    My program has several limitations such as events only (no TO DO, no JOURNAL, no ALARMS, etc), but it was all I needed. The output is acceptable to Lightning and Google.
    If you are computer literate I could give you the source code. You would also need Python on your computer.
    An alternative is to take the exported .ics file and use a text editor on it to delete all the old stuff -- a very tedious process!
    In either case, the overall process would be to export the calendar to an .ics file, cut out the old items, delete everything from your calendar (or just create a new calendar), and then import the cleaned up .ics file.

  • Calendar events older than a month have disappeared!

    I use the calendar on my iPhone and iPad, also synced with my husbands phone) for all our business appointments. In searching for a past appointment the other day, I suddenly discovered that any appointment or event created more than 4 weeks ago has disappeared, from all devices! This is a major headache for us as we rely on using previous events to help book future appointments etc!
    Is this normal? Are events only stored for a period of time? I had assumed they would stay until someone deleted them!
    Really grateful for any help as may have to stop using this feature if it doesn't store events!
    Thanks

    The events should come back. Try refreshing the calendar. Launch the calendar app and tap the calendar button at the bottom. Pull down on the window that opens to refresh the events.

  • Cannot find my calendar events older than one year. Where are they ad how do I get them back?

    I cannot find my old events on iCal. It seems it only goes back one year. How can I find them and recover my information and events going back further than that?

    Greetings,
    Sorry to hear about the missing data.
    If you don't see your events there are 2 possibilities:
    1.) There is something wrong with the calendar cache
    2.) The events have been deleted
    First go to iCal > Preferences > Advanced > Delete events.. -- see if this has been checked as this deletes events after a point in time you specify.  Even if this is not checked now, if it was ever checked in the past, that will delete events.
    To reset iCal's cache and settings in the hope this will bring the events back:
    1. First make an iCal backup:  Click on each calendar on the left hand side of iCal 1 at a time highlighting it's name and then going to File Export > Export and saving the resulting calendar file to a logical location for safekeeping.
    2. Remove the following to the trash and restart your computer:
    Home > Library > Caches > com.apple.ical
    Home > Library > Calendars > Calendar Cache, Cache, Cache 1, 2, 3, etc. (Do not remove Sync Cache or Theme Cache if present)
    Home > Library > Preferences > com.apple.ical (There may be more than one of these. Remove them all.)
    ---NOTE: Removing these files may remove any shared (CalDAV) calendars you may have access to. You will have to re-add those calendars to iCal > Preferences > Accounts.
    Once the computer is back up and running open iCal and test.
    If the events do not come back then the information you are looking for is truly not in iCal.  You will need to restore from a backup (like TimeMachine) from a point in time before the events in question went missing.
    If you do not maintain backups of your computer, start now.
    Depending on how long ago these events were deleted from iCal you can try using data recovery to bring the files back although as these are past events, you may find that just moving forward from here is simplier than going through the effort but that is of course up to you to decide.
    Here are a few examples of data recovery programs:
    http://www.prosofteng.com/products/data_rescue.php
    http://www.macintosh-data-recovery.com/
    http://www.subrosasoft.com/OSXSoftware/index.php?main_page=product_info&products _id=1
    You can contact a local Apple Authorized Provider to see if they offer data recovery services: http://www.apple.com/buy/locator/service/
    There are many nationwide / worldwide data recovery companies out there.  Here are a few examples:
    http://www.ontrackdatarecovery.com
    http://www.drivesaversdatarecovery.com/
    http://www.totalrecall.com/
    Best of luck to you.

  • Calendar sync problem - eliminates events older than 2 weeks

    I sync my blackberry to my Mac using Blackberry Desktop manager.  It works fine except that it erases all events older than 2 weeks old......this is not what i want it to do.  I have adjusted the desktop manager to sync "all events" but it continues to erase older events.  
    What must I adjust to allow sync of all events (old, current and future).  I keep older events for various purposes including to remind me of past events and information.  
    Help.

    try going to blackberry calendar options and set calendar data duration for "forever"..  lot of records to sync, but you keep them.

  • Automatic Deletion of Events In Calender

    I use the calender on the iphone to set up events, but that's all. I don't use iCal on my macbook pro.
    My question is, is there a setting that I can turn on that would automatically get rid of an event that I placed on the calender? I mean I set up all these events like 2 weeks ago, and they still show up on the calender.
    So do I have to manually go to each event, go to edit, and then delete? That's just a pain in the (*#Q$*%

    If you sync calendar events with iCal, this would be possible.
    There is a preference setting to not sync events older than XX days.

Maybe you are looking for