Get the latest tips and tricks directly from the PowerWF development team. Find out about new releases and upcoming features.
Seamless Automation
From the Desktop to the Data Center
The PowerWF family of products are easy enough for desktop and departmental automation, yet powerful and scalable enough for the Data Center. PowerWF compliments Opalis and other RBA solutions, lets you leverage your workforce and preserves your investment as your automation needs grow.
In conjunction with our recently
announced Silver
Award from Windows IT Magazine we
would like to offer our customers an opportunity to save 20%
off any Devfarm product
purchase through the end of the year. This includes all PowerWF products as
well as Devfarm's new PowerVI product!
Designed for the VMware Administrator, PowerVI eases the automation of vSphere infrastructures. PowerVI includes over 100 PowerShell automation scripts that simplify everyday VMware administration tasks and PowerVI makes it easy to author new scripts.
But what if you are doing something more complex where you are pulling data from multiple sources or you want to control every aspect of the structure of the XML you are creating. In that case, I think you have 2 options.
The simplest way would be to build up a string as your xml -
The downside of this approach is that you need to build in you are reinventing the wheel and will therefore be responsible for any error checking and insuring that your final document is well formatted XML.
In many cases, a better way would be to build up your output as psobject/arrays/hashtables/etc. You can then use the PowerShell cmdlets for additional massaging if necessary and use the export-clixml to output it as XML. That would look something like this -
Had a chat on the website today where someone asked -
How do I tell what version of PowerSE I have installed; it doesn’t have a help -> About
It turns out, the way to tell the version of PowerSE is the same way you would tell the version of PowerShell. From the embedded host in PowerSE, type this command:
The install was pretty smooth, yeah. I’ve been tinkering around with it. Uhm..one question, though. Can you tell me more about accessing web services using PowerWF?
Thanks!
Rudi.
Accessing web services is straight forward in both PowerWF and PowerShell. To test it out,
Start PowerWF
Create a new workflow
Click on the Blue PowerShell icon on the toolbar
When the PowerShell editor comes up, click on the Samples button
Enter “Web Service” in the search bar.
Select a PowerShell script that looks interesting – I chose one from the TechNet tab that converts a zip-code to Longitude and Latidude.
Here is the sample I used to test web services:
## Using web services and XML to convert ZIP code to lat lon coordinates ## ## Using web services from NWS to retrieve XML results of ZIP code ## containing the latitude and longitude coordinates, then parse
You can of course alter this script in PowerWF, setting the $zipcode to an input parameter for the script, and adding visualization, etc.
The key to this is to use the new-webserviceProxy activity to set up the web service. This can be done in a script block, as was done here, or by directly dragging over the NewWebServiceProxy activity from the PowerShell toolbox and setting the URI. After the web service object is created, the easiest way to access it is using a PowerShell script block.
Service Manager (SCSM) is a relatively new addition to the System Center suite of products. Service Manager helps automate best practices within an IT organization, especially in cases of incident reporting and problem resolution, change control, and asset lifecycle management. Service Manager is tightly integrated with Operation Manager, Configuration Manager, and Active Directory Domain Services.
Service Manager (SCSM) provides a workflow based authoring tool to handle the logic behind the specific automated actions. PowerWF extends this functionality significantly by allowing users to either create custom toolbox items within the Service Manager authoring tool or to directly create Service Manager management packs. This tutorial discusses how PowerWF can be used to extend the existing Service Manager authoring tool by creating custom toolbox activities.
Topics Discussed
Creating a PowerWF Workflow
Using the embedded PowerShell Editor
Using Auto-Script Creation
Creating Input Parameters
Creating Service Manager (SCSM) Toolbox Activities
Importing and Using Custom Toolbox Activities in Service Manager
Type “Process” in the toolbox search window to find the Get-Process activity. As its name suggest, this activity collect information about the processes running on a computer.
Double-Click the blue PowerShell icon on the getProcess activity to open the PowerShell editor.
Click the Start button to view the output of this activity. The Grid tab shows the complete results in a table format.
One nice feature of PowerWF is the ability to automatically generate PowerShell script based on user interaction with the Grid pane. Find the CPU column and click the heading to sort the results. Next, while holding down the CTRL key, select a cell in the CPU and Name columns.
Note: If desired, additional cells can be selected. Be sure to hold down the CTRL key the entire time while selecting columns.
It is probably no surprise to anyone that knows me that I am a huge fan of XKCD. The comic covers the entire tech-geek spectrum, with topics ranging from math and physics to computers and video games.
In fact, if you open up the PowerWF Studio - Getting Started Guide you will see an XKCD comic prominently displayed on page 7. You did know we had a Getting Started Guide, didn’t you?
Anyway, I thought it would be fun to convert Randall Monroe’s cheat sheet into a real PowerWF workflow…
There are several ways to approach this, but I opted to leverage PowerShell and Visual Basic MsgBoxes so I could show off a few PowerWF features. If you just want to play with the final version of the workflow, you can download it here.
But, if you would like to see how to actually create a workflow that makes decisions based on input from the user, I’ll explain what I did below the fold.
There are times when IT administrators want to find out which processes are running on a machine, and which account is the owner of the process.This tutorial turns a sample PowerShell script that I stumbled upon into an emailed report that contains this information.
Topics Discussed
Importing a PowerShell Script
PowerShell Pipelines
PowerShell getWmiObject cmdlet
PowerShell forEachObject cmdlet
PowerShell selectObject cmdlet
PowerShell sortObject cmdlet
HTML output
Web Browser control
Sending results via SMTP
Procedure
Instead of creating a workflow using the procedure in the previous example, click the down arrow under the New button and select “New Workflow from PowerShell”.
PowerWF will now prompt for a workflow name. Name the workflow “ProcessOwnerReport” and click OK.
In many cases, a quick search of the web will yields a PowerCLI/PowerShell script to do most of the tasks in a workflow. The following script is one such example:
This script looks pretty complex, but once PowerWF interprets it as workflow it will be much easier to understand.
Enter this script in the PowerShell Editor and click OK.
NOTE: The PowerShell editor allows users to open and save PowerShell PS1 files, or test PowerShell scripts. Click the Play button if you want to test the PowerShell script or get an idea of what the output will be like.
PowerWF automatically converts the PowerShell script into a PowerWF workflow. Notice that despite the complexity of the original script, it was actually three main PowerShell cmdlets in a pipeline.
This workflow could be immediately run to collect the desired data, but for this tutorial we will discuss how PowerWF interpretted the script. The forEach-Object is a special case that will be discussed.
The first command in the original script was “Get-WmiObject Win32_Process”. We can see that this was converted into the “getWmiObject” activity with the classname property set to “Win32_Process”.
In PowerShell, the “|” character is used to connect the output of one cmdlet to the input of another cmdlet.
The second part of the script is a little more complex. PowerShell has multiple versions of “For” loops. Without going into a lot of technical details, suffice to say that from a workflow perspective, the example that we found uses the least friendly version, “forEach-Object”.
For the other “For” versions been used, PowerWF creates individual activities for each item. ForEach-Object is a special case that essentially runs an embeded script that is in the “Process” property. In this case the embedded script finds the process owner for each process that is passed into it.
The final command simply selects the Process Name and the Owner that was discovered in the ForEach-Object loop.
At this point, visualization can be added and the script tested. The desired output for this example is an HTML table, so in the toolbox search, type “html”. This will list all HTML related activities. Drag the “ConvertDataToHTML” activity to the workflow Canvas and drop at the bottom of the “pipelineSequence1” activity.
Although the WebBrowser activity can directly convert data to HTML, this activity allows the HTML output to be used as the body of an email.
For a quick visualization the data can be displayed using a web browser. Click the next to the search box to show all activity packs. Drop the webBrowser activity from Visualization into the workflow below the “convertDataToHTML1” activity.
Press the Start button in the ribbon bar to run the workflow. In its current state, the workflow finds the processes and the process owners and displays them as an HTML table.
The results would be more meaningful if the data was sorted based on the process name. Typing “sort” in the search bar finds the “sortObject” PowerShell activity. Drop this in the pipelineSequence below the “selectObject1” activity.
The sort object requires selecting one or more columns to sort on and the sort order (ascending or descending). Add a sort property of Name.
The “convertDataToHTML” and “WebBrowser” activities can display their output in a number of different styles. Set the Style on the “toHTML1” activity to the Onyx style.
Press the Start button in the ribbon bar to run the workflow. The output is now in a meaningful format with a dark-themed display style.
The “WebBrowser” activity can now be deleted and replaced with the “SendMailBySMTP”. This activity can be found by typing “mail” in the search bar. The “SendMailBySMTP” requires slightly more configuration than some other activities. Set the mail server host, user,password and SMTP Port and EnableSSL if necessary.
It is also necessary to configure who the email is “To” and “From”, and the “Subject” of the email. Set the “To” email address to the target recipient and the “From” email address as the user whose credentials are used to connect to the mail server. The “Subject” should be set to something meaningful, such as “Process Owner Report”.
The final steps are to set the “BodyHTML” property to True to configure the output of the “convertDataToHTML1” activity as the Body of the email. Click on the button next to “Body”. Expand the “convertDataToHTML”1 and select “Output”. This will bind the output from the “convertDataToHTML1” activity to the “Body” of the “sendMailBySMTP1” activity.
Up to this point PowerWF connected the output from one step in the workflow to the input of the next item in the workflow. The “sendMailBySMTP” activity is a little different because the upstream outputs could be used as the Subject, the Body, or even as a User or Password.
The other improvement that could be made at this point is to change the table heading from “pipelinSequence1” to something more meaningful. This can be done by renaming the pipeline sequence to “ProcessOwnerSummary”
Press the Start button in the ribbon bar to run the workflow. If everything is configured correctly, an email with snapshot ages should be sent to the target recipient.
Summary
This tutorial showed how to import a PowerShell script into PowerWF Studio and how the script was converted into a workflow. The PowerShell script chosen finds to process owner for each process running on a system. The script was extended by outputting the result as HTML and emailing it via SMTP. 1 year ago - link
I had a customer call in today with an interesting use case that he was having problems with. Essentially he was using the getWMIObject activity to watch the Microsoft Messaging Queues for Bytes Used. He wanted to take the result of the WMI query and store it in SCOM along with the values from two registry keys.
He created a script that got him 90% of the way there, but was struggling with the final data mashup. His initial workflow looked like this…
Query WMI
select BytesinJournalQueue from Win32_PerfFormattedData_msmq_MSMQQueue WHERE Name = “Computer Queues”
The only steps he was missing was using a QueryData activity to turn the three sets of data into a single data table…
In his case the query to combine the data was:
Select pipelineSequence1.BytesinJournalQueue, readRegistryKey1.value As JournalQuota, readRegistryKey11.value As MachineQuota From pipelineSequence1, readRegistryKey1, readRegistryKey11
Then all he needed to do was swap out the webBrowser activity with a toSCOM activity and publish it to System Center using the wizard. After he walked through the wizard, he added a rule to Operations Manager to compare the values and alert if the WMI Query value was larger than either of the registry values.
If someone is standing around talking to themselves, you’ll probably ignore them and move along. If you see people milling around in a group listening to someone, the natural reaction is to stop and see what’s going on.
Twitter is a social setting much like any other social setting - reach out and make a few friends, and soon you will get introduced to more friends. This tutorial will show how PowerWF can help you with the first part; reaching out to people and making new friends. In the twitter world this is done by following people with similar interest.
You following someone is the same as you stopping to listen to what they say. They will take notice, especially if you repeat what they said.
NOTE: This tutorial assumes that the PowerWF Twitter PowerShell Module is installed.
Break it down
If we break this down into more of a workflow, it might be something like:
Find people tweeting about topic X
Find out if what they say is useful:
It contains a link
It contains other key words
It is more of significant length
If it is:
Retweet what they said
Follow them
Download Samples
To use the following samples, unzip them into your workflow directory and open them with PowerWF. Be sure to set the Twitter Usernam according to the tutorial instructions below. You will likely also want to adjust the Twitter Search and QueryData.
Advanced Retweet and Follow Sample This sample contains a production ready version of the workflow that caches results between runs, automatically translates non-english tweets and checks friendship status before adding friends.
Build the workflow
Turning this into a PowerWF script is actually pretty straight forward. We begin with some basic house keeping; creating a workflow and connecting to Twitter. Then we will follow the steps described above.
Click NEW and create a workflow named “retweetAndFollow”.
From the PowerWF.Twitter Toolbox, drag “ConnectTwitter” on to the canvas.