PowerShell

Powershell related code snippets

Retrieving REST based results from SMA Runbooks

In a previous example, I gave an example of running a simple Service Management Automation runbook using REST.  This blog demonstrates how to retrieve output from a called runbook by using platform independent REST calls against the SMA Server. 

Four steps exist in obtaining the output from an SMA Runbook:   

Editing MSI databases with PowerShell

Jason Ginchereau is responsible for the creation of the Windows Deployment Toolkit which is incorporated into WIX.  The toolkit provides extensions for PowerShell to access Windows Installer databases with managed code.  Current releases can be downloaded from: http://wixtoolset.org/releases/

Invoking SMA Runbooks via REST

Service Management Automation Runbooks are PowerShell workflows.  Workflows allow parameters to be passed in at the time of execution and are essential to any infrastructure automation. 

Calling Orchestrator Runbooks (& retrieving output) via REST

This example uses PowerShell to call an Orchestrator runbook and display the results.

To demonstrate the scripting, I have created a simple runbook that will accept a string input.  It’s titled “Input1”.

Creating SCCM Global Conditions by Script

I’ve written a fair bit about automating SCCM application creation by script.  Most of this has originated from the need to use Enhanced Detection Methods for determining when Applications are installed as I know from many years of Application Packaging that unless an official “package” produces a standard file or registry based flag when it’s installed, it becomes impossible to tightly manage a software environment. 

Listing SCCM Application Requirements

The code snippet below is an example of how to recursively list all of the requirements that have been set against SCCM Applications within an environment.

Using XML Lookup Files with Orchestrator

There can be many reasons for needing site specific data related to an IP address.  I had a recent requirement for Orchestrator to configure machines when the only input was the IP Address of the target machine.   This solution uses PowerShell to compare an IP Address to an XML based lookup table of site information.  By finding the right site, other locale details can be used through Orchestrator.  The XML below represents the site information needed by my particular process.

Example Scripting - SCCM 2012 Application Dependencies

A number of previous posts have provided examples of how to script against SCCM 2012 Applications.

The script below is an example of how to attach a Deployment Type dependency rule to a scripted application.  If you havent done so, take the time to have a look at my recent blog into SCCM rules to get a better idea of what is happening.

Constructing SCCM Rules with PowerShell

System Center heavily uses rules for definining how software elements relate with each other.  They aren't extensively documented but must be understood by anyone trying to script SCCM applications.   At the highest level, a rule can be seen to comprise of an Expression and an Annotation that are combined with an overall severity level for noncompliance.  The same structure I used throughout System Center so the severity level of noncompliance changes on the type of rule being used. 

Pages

Subscribe to RSS - PowerShell