Script to cleear data workflow history lists

sns 9,251 Reputation points
2023-02-21T17:54:34+00:00

We have 1100 sub sites in CSV and each sub site has list called "Nintex Workflow History" list

Now after selecting below "NintexWorkflowHistory" list on ribbon there is option to PURGE.

I have command to purge Nintex workflow History

Is there any script to reach to this list and execute that command. I know command. I just need to put that command in the script and perform operation on this list for 1100 sites.

Please suggest.

In case if you think this is 3rd party I just need your suggestion how we can achieve this with script.

User's image

Microsoft 365 and Office | SharePoint Server | For business
0 comments No comments
{count} votes

Answer accepted by question author
  1. RaytheonXie_MSFT 40,496 Reputation points Microsoft External Staff
    2023-02-22T02:44:41.6166667+00:00

    Hi @sns,

    Per my test, I have a csv like following pic

    User's image

    And you can read the csv by following script then delete the list in these Url

    Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue 
    
    #Read urls in csv
    $Items = Import-Csv -Path C:\xie\SPurl.csv
    $Urls = $Items.Url
    Write-Output $Urls
    
    #loop each url and get the list in site
    foreach($Url in $Urls){
        $SPWeb = Get-SPWeb $Url
        $SPList = $SPWeb.Lists["NintexWorkflowHistory"]
        $SPList.AllowDeletion = $true
        $SPList.Update()
        $SPList.Delete()
        write-host "List has been deleted successfully!"
    }
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.


1 additional answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,496 Reputation points Microsoft External Staff
    2023-02-23T05:06:31.05+00:00

    Hi @sns,

    You can use the following script to purge history

    Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue 
    #Read urls in csv
    $Items = Import-Csv -Path C:\xie\SPurl.csv
    $Urls = $Items.Url
    Write-Output $Urls
    #loop each url and get the list in site
    foreach($Url in $Urls){
    $web = Get-SPWeb $Url
    NWAdmin.exe -o PurgehistoryListData -state completed -url $Url
    }
    
    2 people found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.