Anyone running into issue trying to purge old version from powershell in Tridion 2013?

I am running the following command:

Remove-TcmItemsOldVersions –ContainerItemIds(Get-TcmRepository).id –VersionsToKeep 5 -recursive


Remove-TcmItemsOldVersions : This request operation sent to net.tcp://localhost:2660/CoreService/2012/netTcp did not receive a reply within the configured timeout (00:01:00). The time allotted to this operation may have been a portion of a longer timeout. This may be because the service is still processing the operation or because the service was unable to send a reply message. Please consider increasing the operation timeout (by casting the channel/proxy to IContextChannel and setting the OperationTimeout property) and ensure that the service is able to connect to the client.


I tried it for just one publication and getting a timeout as well.

Here's the command for one pub:

Remove-TcmItemsOldVersions –ContainerItemIds "tcm:x-x-x" –VersionsToKeep 5 -recursive

In my Tridion\web\web.config I included this new endpoint behavior for netTcp_2012

<endpoint name="netTcp_2012" address="net.tcp://localhost:2660/CoreService/2012/netTcp" binding="netTcpBinding" bindingConfiguration="CoreService_netTcpBinding" contract="Tridion.ContentManager.CoreService.Client.ISessionAwareCoreService" behaviorConfiguration="Tridion.ContentManager.CoreServiceBehavior"/>

     <!-- some other behavior name might exist here -->
      <behavior name="Tridion.ContentManager.CoreServiceBehavior">
         <dataContractSerializer maxItemsInObjectGraph="2147483647"/>

It does not seem to be working still....

3 Answers 3


The netTCP endpoint is configured in TcmServiceHost.exe.config rather than the web.config.

See an example from Eric Huiza to my question on configuring netTcp for SDL Tridion 2013.

Also be sure the service is running. :-)

  • Hi Alvin, I don't think the purge script is working even modifying the TcmServiceHost.exe.config. I submitted a ticket to SDL support and they said that it's a known issue which will be addressed in Tridion 2013 SP1
    – Robert Jin
    Nov 15, 2013 at 7:07

Robert Jin is right.

First of all, when you execute powershell script - the WCF client is powershell, but not IIS(so your changes to web.cfg will not give any effect). But powershell hasn't configuration file and all ServiceModel configuration is set manually in the TCM.Automation assembly (by c# code).

During implementation of the automation scripts - TimeOut binding was not specified, so default value 1 minute is taken (it is WCF constant).

This was fixed in 2013 SP1(probably it is not delivered yet) - you can specify Timeout value in the powerShell script.

BTW, the same problem for other powerShell scripts in 2013.

For WorkAround I can suggest:

1) Don't call this script on big amount of data(publications with many items).

2) Use CoreService and it's public API directly.

ICoreService2012.PurgeOldVersions(PurgeOldVersionsInstructionData instruction);
  • Powershell does/can have a config file, down in the depths of the system where the executable lives. The machine config would also work... but still, there's really no need if you can configure from code. Dec 6, 2013 at 12:18

You can do a purge from the Powershell directly using the core service client. I probably wouldn't do it quite like this. In practice, I'd usually use Peter Kjaer's Powershell module to get the client, but here's some raw code that shows how you might set up your quotas. (lifted from my own blog) You could also wire up Endpoint behaviours in a similar way.

Add-Type -assemblyName System.ServiceModel
$binding = new-object System.ServiceModel.WsHttpBinding
$binding.MaxBufferPoolSize = [int]::MaxValue
$binding.MaxReceivedMessageSize = [int]::MaxValue
$binding.ReaderQuotas.MaxArrayLength = [int]::MaxValue
$binding.ReaderQuotas.MaxBytesPerRead = [int]::MaxValue
$binding.ReaderQuotas.MaxNameTableCharCount = [int]::MaxValue
$binding.ReaderQuotas.MaxStringContentLength = [int]::MaxValue
$endpoint = new-object System.ServiceModel.EndpointAddress http://localhost/webservices/CoreService2011.svc/wsHttp
Add-Type -Path 'C:\Program Files (x86)\Tridion\bin\client\Tridion.ContentManager.CoreService.Client.dll'
$core = new-object Tridion.ContentManager.CoreService.Client.SessionAwareCoreServiceClient $binding,$endpoint

Once you've got that far, you can use the PurgeOldVersions API directly.

$purgeInstruction = new-object     Tridion.ContentManager.CoreService.Client.PurgeOldVersionsInstructionData
$linkToFolder = new-object Tridion.ContentManager.CoreService.Client.LinkToIdentifiableObjectData
$linkToFolder.IdRef = "tcm:1092-2243-2"
$purgeInstruction.Containers = @($linkToFolder)
$purgeInstruction.VersionsToKeep = 2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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