In my last post I walked you through creating a workflow based on a template (the included “Start Stopped Services” workflow.) In that post I mentioned that you might want to modify the workflow to only show services that are not in the disabled state and suggested you try to figure out how to do that on your own: Previous Post

 Let’s take a look at the previous workflow we created to see how it is structured:

 This workflow has 5 basic steps:

  1. Get all the installed services (Get-Service)
  2. Filter out all the stopped services (Where-Object)
  3. Sort the list of services in alphabetical order for display to the user (Sort-Object)
  4. Display the sorted list to the user and allow them to choose a subset of services to start (User Option)
  5. Start the services that were selected by the user (For Each Object)

 It should be obvious that if we modify the “Where-Object” task to also filter out services that are Disabled in addition to the Stopped ones we can achieve the desired result. Unfortunately, the Status property only returns two different values – “Running” and “Stopped”. We need to take a look at what other properties there are on the Get-Service task that we could use. The easiest way to do this is to just output the entire object to a file and take a look at what is there. We include two tasks with Workflow Studio that allow you to send objects to a file – “Export To CSV” and Export To XML”. Both of these tasks also include a property to auto-generate an HTML wrapper for the data so you can quickly view the data as well.

 To use this debugging technique, just add the additional task from the Input/Output folder (either CSV or XML) and connect it to the “Get-Service” task:

 There is no need to delete the other tasks as Workflow Studio will only run the tasks that are connected in the workflow. On the newly added task you will have to set the “Input Variable” property to “$Services” and the “Output XML File” property to a valid local path and pick a filename. I also set the “Save As HTML” and “Show HTML” properties to TRUE so that I get an immediate, readable HTML report of the object like this:

 If you have followed along this far I hope that this helps you understand how you can output objects to a file for debugging purposes (or you may need to do it to provide files to other processes.) When you look at the properties that are available from the Get-Service task you will find that there is not a property available that will allow you to determine if a service is Disabled. The Get-Service task is based directly on the Get-Service PowerShell cmdlet and this is a limitation of that cmdlet. So we went through this whole process and have hit a dead end with our goal of filtering out disabled services. Next time I will provide the solution to this problem, but in the mean time here is a good hint: