question

RaeesK-7989 avatar image
0 Votes"
RaeesK-7989 asked JerryXu-MSFT commented

Change the Workflow autocleanup retention days in SharePoint Server 2019

Dear,

Is there any possible way to change the workflow auto cleanup days from 60 days to 365 days for SharePoint Server 2019. Facing may issues due to the auto cleanup. Kindly help.

Regards,

office-sharepoint-server-administration
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, @RaeesK-7989 ,

Have you tried the script? Does it work for you?

Feel free to reply with any update about it.

0 Votes 0 ·

1 Answer

JerryXu-MSFT avatar image
0 Votes"
JerryXu-MSFT answered

Hi, @RaeesK-7989 ,

You can use PowerShell to change the AutoCleanUpDays property of workflow from default 60 days to 365. It is a workflow level property so you can change only the required workflows. And workflows are associated to list, you need to know the list name.

Here are scripts work in my end:

For changing a specific workflow:

 $site=get-spweb -site "<siteURL>"
 $list=$site.lists["<ListName>"]
 $wfs=$list.WorkflowAssociations
 $wf=$wfs.GetAssociationByName("<WorkflowName>","en-US")
 $wf.autocleanupdays=365
 $wfs.update($wf)

And if you want to change all the workflow in a list.

 $site=get-spweb -site "<SiteURL>"
 $list=$site.lists["<ListName>"]
 $wfs=$list.WorkflowAssociations
 for ($i = 0; $i -lt $wfs.Count; $i++)
 {
     $wf=$wfs[$i]
     $wf.autocleanupdays=365
     $wfs.update($wf)
 }

Let me know if it works well or not.


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.