Calendar maintenance tools? | MDaemon Technologies, Ltd.

Calendar maintenance tools?


  • Is there a calendar tool for MDaemon Calendars?

    Basically I have users with over 20 years of calendar events that have long past and I would like to be able to trim/purge events that took place in the past x days, without having to manually edit the xml files.

    I've looked all over the manual, and I can find ways to do it with emails, but nothing on Calendar events.



  • I sent you a link to download a powershell script that will remove old appointments and events from user's calendar.  Please make sure you test the functionality prior to running it on your live server and make sure you backup all the calendars prior to running the script.

    Let me know if you have any questions.


  • Thank you so much! I'll give it a try.


  • @Arron 

    Hello

    I'm also interested in that powershell script to remove old appointments and events. Could you send the link to me?

    Thank you


  • Sure, you can download the powershell script at https://mdaemon.sharefile.com/public/share/web-sb4ea1c9ab15444ebb3561901b3fb9c24.  Please make sure to backup all of your calendar.mrk files prior to running the script.  And be sure to test it before running it on your live server.


  • @Arron 

    How can I test it before?

    I have repeating events that I defined years ago. They are scheduled to recur every year, every six months, etc... Will this script delete current and future recurrences of those events?

    Thank you


  • How can I test it before?

    1. You can install an MDaemon trial on a test server and copy your calendar over to it.  

    2. You can create a test account on your existing MDaemon, copy your calendar to the test account and then edit the script and add the following at line 244.

    $PathtoUserFolders = "c:\mdaemon\users\domain\mailbox"

    It should be just above this line:

    write-Host "The path to the users folders is set to $PathtoUserFolders"

    You'll want to point it at the test user accounts actual mailbox.  For safety, I'd reccomend backup up all calendars on your live server before doing this.  

    3. You can backup all calendars on your live server and run the script on your live server.  If it does something you don't like, restore the backup copies of your calendars.  

    4. You don't actually need MDaemon to test it at all, so you could just copy your calendar to another location and set the path to the file as described above.  I would not reccomend doing this on your live server though, because if you get it wrong, it could easily prune your actual calendar.  

    When you backup your calendars make sure you backup the entire calendar folder.

    Will this script delete current and future recurrences of those events?

    It should not.  The script will only remove event if the recurrence end date is set and its older than the limit that is set.


  • @Arron 

    Ok, thanks for your anwers.

    I need run the script only for one account. So perhaps, the easiest option is the 4th, but as you recommend, coping it and running it in other server.

    Will the next steps?
    1) backup the Calendar.IMAP folder and calendar.mrk file
    2) copy the Calendar.IMAP folder and calendar.mrk file to another server
    3) run the script in the other server
    4) restore the Calendar.IMAP folder and the calendar.mrk file from the other server to Mdaemon server
    5) Check the result
    6) If I find problems, restore the Calendar.IMAP folder and calendar.mrk file from backup

    Is it correct?


  • That should work fine and provides a backup copy of the entire calendar in case something goes wrong.

    I did miss one small step though.  If you run the script on a server that MDaemon has not been installed on, it won't be able to find the regitry keys and it will exit.  To allow the script to continue running edit the script and on line 231 insert a # character at the beginning of the line so it looks like this:

        #Exit

    This will allow the script to continue running even though it could not find the registry keys.


  • @Arron 

    I've run the script in other machine over the folder tree copied from Mdaemon server, with the changes which you recommend to me. 

    I think the script haven't deleted any ics file: On the screen it looked like running well, it found a lot of events (hundred or more) and it said that deleted that events. I suppose it deleted the events on the *.mrk file, but I think it didn't delete the corresponding ics files.
    It created a backup of mrk files and it created a new mrk file which is smaller than the original.

    But before run the script, there were more than 4000 files, and after run there still were more than 4000 files. Because of this, I think the script didn't deleted any ics file.

    Also, after processing all events at the end of running, the script give an error about the xlm conversion, but I think is a problem with powershell version or modules and I think it doesn't related with the deleted of the ics files because I think the script should delete the ics files when it found each event, doesn't it?

    Best regards


  • Please zip your entire Calendar.IMAP folder from before you ran the script and upload it https://mdaemon.sharefile.com/r-r77d4332c21ab4a28afe9e84ea94e2f3c.  I'll take a look at see what is going on.


  • @Arron 

    I'just uploaded the calendar.imap folder and the calendar.mrk file.

    I studied the code of script, and I think that the script should write a line to warn about the deleting of each ics file associated with each event to be deleted. But the script didn't write any line with this information in the lines written with each found event when I did run it.

    Also the error of powershell after looking for events is:

    No se puede convertir el valor "System.Object[]" al tipo "System.Xml.XmlDocument". Error: "No se puede insertar el
    nodo especificado como elemento secundario válido de este nodo, porque el nodo especificado es incorrecto."
    En C:\temp\PruneCalendarMRK.ps1: 283 Carácter: 5
    +     $Data = [Xml] (Get-Content $File)
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvalidCastToXmlDocument

    It correspondes with the line of script:

    $Data = [Xml] (Get-Content $File)

    I did run the script in a Windows Server 2012R2 64 bits and in a Windows 10 Pro 64 bits. The error was the same when I run the script in both systems. And also, the ics files weren't deleted when I did run the script in both systems.

    Thanks


  • I haven't been able to reproduce the error you are seeing, but I did find a number of other bugs that prevented ICS files from being removed.  I have fixed all that I found.

    I also added functionality so that when an event is removed any attachments associated with it will also be removed. 

    Please download the file again using the same link, you should get a script that was modified today.  If the date at the top of the file is not today, 3/4/2024, let me know.

    Then run the script, with Powershell running elevated, and let me know if you are still having issues.

     


  • @Arron 

    Thanks for the changes in the code.

    I've download the new version of the script and I run it over my backup tree. Now it has deleted about 2400 files: 1752 files remain in the _DAV folder from 4121. So this works fine.

    By other hand, I think that I've discovered the reason of error with " $Data = [Xml] (Get-Content $File)" sentence:  in the user's root folder, there is a calendar.mrk file (c:\mdaemon\users\my.domain\username\calendar.mrk). I'm afraid this file is a ancient rest of mdaemon from the year 2002. Please, check this file in the zip which I did upload some days ago. This file isn't a Xml file, the content of this file is similar to the next:

    [CalendarWriteAccess]
    Default=No
    [CalendarReadAccess]
    Default=Yes
    [2002-08-08 12:00]
    EventStart=2002-08-08 12:00
    EventEnd=2002-08-08 13:00
    Reminder=2002-08-08 11:45
    EventCreator=username@my.domain
    EventText=The text of event
    IsPrivate=Yes
    IsMeeting=No
    IsOutOfOffice=Yes

    So I think the error is because this file does not contain information in xml format.

    Should I delete this file? (This user is the only one with a calendar.mrk file in his user's root folder)

     

    Finally, I've found another problem with the code: The directives in the file "AccountTemplates.dat" are in Spanish. So the directive "[New Accounts]" appears as "[Cuentas Nuevas]" in the file. Because of this the code returns another error at the start of execution. I think the code, for using it with spanish versions, should change the line:

    $PathtoUserFolders = $AccounteTemplatesContent["New Accounts"]["RootMailPath"]

    to

    $PathtoUserFolders = $AccounteTemplatesContent["Cuentas Nuevas"]["RootMailPath"]

    I think this change is important for any other Mdaemon non-english user to avoid errors in the execution of the script, don't you think?

     


  • in the user's root folder, there is a calendar.mrk file (c:\mdaemon\users\my.domain\username\calendar.mrk)

    Yes you an delete this file.

    Finally, I've found another problem with the code: The directives in the file "AccountTemplates.dat" are in Spanish. So the directive "[New Accounts]" appears as "[Cuentas Nuevas]" in the file.

    I'll update the script to prompt the user for the path if the path found does not exist, thanks for the report.


  • @Arron 

    Thanks for your replies.

    I did run the script over the copy of the folder and I copied back it on the user's folder of Mdaemon.
    Everything looks like it works fine.
    Thank you very much


Please login to reply this topic!