OIS - Integration Pack for PowerShell Script Execution 1.00

Good Morning Readers/Viewers!

Today, I am happy to announce the next addition to my collection of OIS 6.3 QIK based IPs on CodePlex. As you can see from the blog title, this one is all about PowerShell. :)


ORCHESTRATOR RC UPDATE (11/01/2011)

CodePlex Links:

NOTE: The rest of this post is unchanged, and can be referenced for OIS 6.3 or Orchestrator.


BACKGROUND:
If you have worked with PowerShell in OIS, you have likely needed to reference blog posts which address workarounds for PS running from x64 machines:

My goal in building this IP was to eliminate the need for this workaround using the “Run .Net Script” object. In the workaround, not only do you have to increase the number of scripting lines, but you also have to include credential information (either as plain text in the script or stored as plain text in an OIS variable). I believe both of these limitations from the workaround have been addressed with this IP.

THE INTEGRATION PACK:
First, here is the link to the CodePlex Project: https://opalis.codeplex.com/releases/view/65652

The Integration Pack for PowerShell Script Execution provides extended PowerShell Scripting capability for OIS and PowerShell (executed from and against both x86 and x64 OSs).

This Integration Pack adds the following objects to Opalis Integration Server:

  • Execute PS Script
  • Execute PS Script – Global

image

NOTE: I have included a User Guide which takes you through the configuration and object specifications.

EXAMPLE CONFIGURATION AND EXECUTION:
As I do not have an “8-Minute-Video” for this yet, I will walk through an example configuration and execution for this Integration Pack:

Step 1: Create a Connection
image
NOTE: This step is only required if you plan on using the “Execute PS Script – Global” object. You also have the option to configure all settings at the object level using the “Execute PS Script” object (where you can take advantage of Published Data, Variables, etc. to make the connection/object more dynamic).

Step 2: Configure an Object
image
NOTE: You will see that there is no extraneous PSSession or ScriptBlock code required. There is also no need to string all the lines of script together separated by ";". Because this is just like a standard OIS object, you can use Published Data and Variables to make the script 100% dynamic (I have left the script static so you can see what I am executing in the example).

Step 3: Run the Object
image
NOTE: In this example, only one PS Script was executed, resulting in just one result (both count and result are highlighted in the above image). Each of these objects have the ability to execute up to five independent PS Scripts (as well as output Write-Host commands if desired). Each PS Script output can range from one single-line data output to multi-line correlated data output. Unfortunately, unlike the "Run .Net Script" object, you cannot create your own correlated Published Data items. Each of the individual PS Script executions is unique. This optional functionality should only be used if you can predict that the output from each script will be aligned.

EXAMPLE USAGE:
Now I will walk through some example usage for this Integration Pack:

Example Usage: Multiple PS Scripts and Multi-line Correlated Data Output

image
PS Script 01

image
PS Script 02

image
Output from PS Script 01 and PS Script 02 Execution

Example Usage: Single PS Script 01 Execution with Write-Host in Output Option Enabled and Filtering

image
PS Script 01 with Write-Host Command

image
Optional Filter on the PS Execution 01 Results (data output will be limited to values which contain "Opalis")

image
PS Execution 01 Filtered Results - NOTE: The output for each PS Script execution can be filtered independently. You can see that even though only three filtered results were returned for the PS Script 01, the "Write-Host" Results contained unfiltered data to include with "Write-Host" command output.

image
PS Execution 01 Results (with Write-Host) - NOTE: The "Write-Host" commands will be collected and displayed at the end of any other execution results. If you wanted to, you could filter these results on a specific key word that may be in all your "Write-Host" commands, so all you see is "Write-Host" output. This functionality is Optional and will likely only be used during testing.

Example Usage: Single PS Script 01 Execution with Error Output

image
PS Script 01 configured against a Local Server Connection without the VMM PowerShell Snap-ins Installed, Standard $error Variable included in Script

image
PS Execution 01 Results with Error Output (because the $error variable was used) - NOTE: Even though the object completed successfully, didn’t mean that the commands executed correctly. If you want to check for errors in your PS Script, simply enter the $error variable at the end of your script, if there are errors, they will be appended to the output. You can see that the commands were not successful because this Local Server does not have the VMM PowerShell Snap-ins as was expected by the PS Script.

ENDING COMMENTS:
I realize that this Integration Pack will not solve all problems with PowerShell execution from OIS. I also know that it will not address absolutely every need. I just wanted to get something out there to fill the gap between now (OIS 6.3) and the future release of System Center Orchestrator. If nothing else, you should be able to see that new and different (sometimes even better) solutions can be built with the tools you already have at your disposal. This Integration Pack was 100% developed with the current version of QIK against the available PowerShell SDK (System.Management.Automation).

enJOY!