6

I have read the documentation on how to purge old items. It describes using the Remove-TcmItemsOldVersions PowerShell script to do this. I am running into a number of issues with the script

  1. We have about 300 publications, each with thousands of folders. This requires calling the script for the root folder of every publication
  2. When calling this script with the recursive parameter set to true, the script consistently times out.
  3. There seems to be no way to filter on item types (i.e. Components, Schemas, Multimedia Components and Templates etc

We would like to run this script daily, but at this point we can’t execute the script on a single root folder without it timing out. How do other people handle this challenge?

My thought is to write a custom C# script which runs daily that recursively iterates through the Publications and their folders, and calls the Core Services PurgeOldVersions(purgeIntructions) method for each folder and its children separately. I feel like this is inefficient, but the only way to get manageable transaction sizes which won’t time out. Does this seem like a sensible approach? If I do use this approach, is there a way to filter on ItemTypes? Or would I need to get list of each folder (with a filter) and then review the history of each item in the list?

  • Did you try adding the timeout parameter? TimeOut: An optional integer ( Int32) indicating the amount of time (in minutes) to wait before considering the purge operation to have timed out. If left unspecified, the timeout defaults to 10 minutes. – premkumar subramanian Feb 3 '16 at 14:31
2

Note that Remove-TcmItemsOldVersions isn't a PowerShell script, but a PowerShell cmdlet.

The beauty of PowerShell cmdlets is that you can create a PowerShell script that uses them. I would strongly recommend to go that way instead of creating your own C# script.

For example, something like:

Get-TcmRepository | ForEach-Object { Remove-TcmItemsOldVersions $_.Id }

Once you have this automated an run regularly, it shouldn't take long to purge old versions of all items in a Publication. For an initial run, you can indeed use the TimeOut parameter and be very patient. :-)

  • thanks Rick. Is there any way to filter this on ItemType? Or will this alway do all items? – Chris Summers Feb 3 '16 at 20:14
4

Depending on timeout error you have:

  1. If it is a CoreService timeout error: use -TimeOut option in cmdlet
  2. If it is a database query execution timeout: use commandTimeout and longCommandTimeout attributes in database connection string (they both take value in seconds, so if you want a 30 minutes timeout the value should be 1800).

Unfortunately, it is not possible to filter by item type. It will be executed for all Versioned items such as: Components, Component Templates, Pages, Page Templates, Schemas and Template Building Blocks.

There is also an option -MaxResolvedItemsCount (100000 by default), which can help you to limit items to be purged for one run.

For the full list of available options and their descriptions you can simply run following powershell command:

Get-Help Remove-TcmItemsOldVersions -Full
  • You can filter by ItemType, but not in the cmdlet directly. PurgeOldVersionsEventArgs show all items, which will be deleted(purged) and you can filter that list. – Syav4eg Feb 4 '16 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.