Monday, 14 January 2013

Search MS Dynamics CRM 2011 workflow definition (xaml) in PowerShell

Sometimes it's necessary to search the workflow definition quickly for an action, for instance: creating a task or creating a custom entity. If you have a few workflows in the system then you can probably get away with looking at them manually from the GUI, if you have many then it makes sense to search the xaml definition file.

The simplest option is described here:

  1. Export the solution containing your workflows.
  2. Extract the solution to a directory.
  3. Start PowerShell and navigate to the directory above.
  4. Search the definition with the following command, which will provide you with the filename:
 ls -Include *.xaml -Recurse | Select-String "YourSearchString" | Group-Object -Property filename | Format-List -Property name
Note that by default YourSearchString will be read as regular expression.

If you want to do negative matching you could try this:
 ls -Include *.xaml -Recurse | Select-String "YourSearchString" -NotMatch | Group-Object -Property filename | Format-List -Property name
This command can be very slow as the notmatches are going to be a lot more than the matches in the xaml, so use it at your peril.

No comments:

Post a Comment