This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Possible to attached Workflow output as CSV?


I'm using a scheduled Workflow to first locate and then deprovision inactive user accounts in AD. By itself the Workflow is fine (only using native tasks) and with the option enabled to "Attach a report of workflow execution to notification message", I receive a little HTML file with the overview of what happened, which accounts were found etc etc. Unfortunately, in their efforts to make the HTML "look nice", its kind of lost its functionality as a "raw output file". In other words, the HTML isn't that easy for administrators looking to create a quick overview or transfer results into Excel file etc

My question is whether or not it would be possible to have the output of the initial Query delivered/exported as a CSV file? So just to have a few values of each account (username etc) in a CSV? Best would be to have that file delivered along with a "Workflow has been executed successfully" message.

Thanks in advance for your help! Best regards,



PS: Running ARS v6.9

  • Hello,

    This is not possible out of the box, even in version 7.0.3. There is an open enhancement request for this, I put it in myself a couple of years back. The best way to get output through ARS workflows unfortunately is to build the CSV or XML programmatically, output to a file then email the file. Just remember to keep your code with the onInit() function for the workflow step if you do it this way.
  • Hey Jamal,

    Thanks for the info! Good to see this request was already raised by yourself (but then again, if it was years ago already, I won't hold my breath for delivery).

    Regarding the scripted solution you mentioned; could you maybe give me a little pointer on how such a script would like (very basic of course)? I don't have much experience with composing those.. Also, I assume this script would just have be added right after the "Find users" step in the workflow? Or is it triggered differently?
  • If you are using a Search activity to find the users to deprovision, you just need a very simple bit of code to export that list.

    You would create a script module that receives the user info from the Search.

    Now the tricky bit of that is how the Search activity transfers the users - they are in an object called "workflow.FoundObject".

    Suppose your Search is called "Find Users to Deprov"

    Here's a very simple script that you can pair with your Search activity:

    Function ExportFoundUsers ($Request)

    $UserDN = $workflow.FoundObject("Find Users to Deprov").get("distinguishedName")

    # Write the user DN to a file
    Add-Content -Path "DeprovedUsers.txt" -Value $UserDN

    You take the above code and place it into an ActiveRoles Policy script which you create in the Script Modules section of the AR MMC.

    The above code is called for each user found. You will need to make sure that you place the script activity inside the gray box that surrounds the Search activity in the workflow.

    The code to send the file would be something like this:

    Function SendOutFile


    # E-mail the file to someone

    $NotifiedUser = ""

    Send-MailMessage -From "" -To "" -Attachments "DeprovedUsers.txt"`
    -Subject "Deproved User List" -Body "See attached list of deproved users" -SmtpServer ""


    You can put this in a script activity that is outside of the Search's gray box. 

  • Great stuff, thanks a lot for taking the time to outline the process and especially for providing the example scripts - really useful!!