cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to check NWAdmin commands required -url as parameters in PowerShell?

Jump to solution

Through powershell I want to execute NWAdmin commands. I have written simple command as shown below.

$spWebURL = Read-Host "Enter Web Application URL:"

$spWebApp = Get-SPWebApplication $spWebURL

$NWAdminCommand = Read-Host "Enter NWAdmin Command to perform request action:"

if(Test-Path(".\NWAdmin.exe"))

{

foreach ($SPSite in $spWebApp.Sites)

{

    foreach($SPWeb in $SPSite.AllWebs)

    {

  $SiteURL= $SPWeb.URL;

 

  $NWAdminCommandTest=".\NWAdmin.exe -o $NWAdminCommand -url $SiteURL";

  

  iex $NWAdminCommandTest;

  

    }

}

}

 

 

 

NWAdmin commands format is shown below.

NWAdmin.exe -o PurgeWorkflowData [-workflowName workflowName] [-state[All|Running|Completed|Cancelled|Error]] [-url teamsiteUrl [-listName listName]] [-deletedLists]

 

How to check if user enter PurgeWorkflowData as command, is NWAdmin commands required -url as parameters?

Labels: (2)
0 Kudos
Reply
1 Reply
Automation Master
Automation Master

Re: How to check NWAdmin commands required -url as parameters in PowerShell?

Jump to solution

I must first say, giving someone, even an admin, a delete all command for every web in a webapplication is very dangerous. There are side effects to PurgeWorkflowData and other NWAdmin commands. I would not run the script expecting a PurgeWorkflowData command in production without much planning and backups. Let me first provide some information on PurgeWorkflowData before I explain what may be the issue you are running into.

 

NWAdmin.exe -o PurgeWorkflowData [-workflowName workflowName] [-state [All|Running|Completed|Cancelled|Error]] [-url teamsiteUrl [-listName listName]] [-deletedLists] [-lastActivityBeforeUTC lastActivityBeforeDateUTC | -lastActivityBeforeLocal lastActivityBeforeDateLocal] [-listId listId] [-itemId itemId] [-instanceId workflowInstanceId] [-initiator loginname] [-timeout seconds] [-silent] [-purgeAll | -deletedSites]

 

Description

This operation is used to remove historic data from the Nintex Workflow database. Reasons that data may need to be removed include:

1. Removing old data to decrease the size of the Nintex Workflow content databases.

2. Removing data added during testing of a workflow.

The operation accepts a number of arguments to use in combination to build up a filter of which data to remove. Before executing the operation, a summary of the selected filters will be displayed for confirmation. Only database entries matching all entered criteria will be purged.

Once data has been purged, it cannot be recovered without restoring a backed up version of the database.

Consequences

After this command has run, Nintex Workflow will no longer have any record that the affected workflows were executed. The affected workflow instances will:

 No longer be listed as having run on the ‘view workflow history’ page.

 No longer be able to have their graphical status of detailed history viewed.

 No longer affect statistics or reports.

 No longer appear in web parts.

 No longer have viewable tasks (the task item will exist, but clicking on it will receive and error about not being able to find the ID in the database).

 No longer be able to have history list items associated with them purged using the ‘PurgeHistoryListData’ command unless the–clearall switch is used.

SharePoint views, such as accessing the ‘workflows’ link of a list item, will still display the workflow.

 

You need to know this and plan for it before allowing someone to run such a command. If you are purging test data, then you will also need to run PurgeHistoryListData for a full cleanup (run this command first if doing so).

 

These operations are hard to recover from, plan accordingly.

 

But, back to your question, is -url parameter required for PurgeWorkflowData? No, it is not. The parameters build a filter to what you want to delete, leaving out filters will delete more data. If you do not use the -silent in the command you will be prompted to accept the consequences before each deletion in each site. In a looping script, that will be cumbersome. Also, this takes a lot of time to do depending on the number of sites you have and amount of data.

View solution in original post

0 Kudos
Reply