In large migrations, huge Workflow History lists can cause a bottle-neck in migration performance. It's sometimes a good idea to filter out the Workflow History, if not required. However, in some cases, the information is crucial and needs to be carried across. In such cases, we can use a PowerShell transformer script to filter out old Workflow History items as per business needs.
Heavy use of SharePoint naturally results in huge Workflow History list. However, it's possible to keep it in check by choosing a new Workflow History list for each workflow or by placing governance policies in advance.
Note: Make sure to enable the Advanced Mode on the Settings tab of the Content Matrix Console to see all the job configuration options.
# Begin Transform to identify Workflows History list $isWorkflowHistory = $false if ($sources.parentlist.name -eq "Workflow History") { $isWorkflowHistory = $true }
# Transform Step to filter out items older than 60 days if ($isWorkflowHistory -eq $true) { $currentdateTime = (Get-Date) $days = New-TimeSpan -Start $dataObject.Modified.Date -End $currentdateTime if($days.Days -ge 60) { #$days.Days | Out-File "C:\temp\printingdifferenceindates.txt" -Append $dataObject = $NULL } }
When the action is run, the Workflow History items that are older than 60 days will get filtered out.
Note: Instead of pasting the code directly into the configuration, you may point the Begin Transformations and Transform tabs to their respective scripts by choosing "Use Script From File". Download the change the extension of the attached scripts to .ps1
DISCLAIMER
© ALL RIGHTS RESERVED. Feedback Terms of Use Privacy Cookie Preference Center