Summary: Make data from a Windows PowerShell script in System Center 2012 Orchestrator accessible on the data bus.
Hey, Scripting Guy!
We love using Windows PowerShell with System Center 2012 Orchestrator, but we’re having a hard time figuring out how to get our data to Orchestrator from Windows PowerShell. Can you lend us a hand? Please? Pretty please?
—TS
Hello TS,
Honorary Scripting Guy, Sean Kearney here. I’m continuing to fill in for Ed this week.
So last time we saw how to get data IN to Windows PowerShell from Orchestrator:
Access Data from Orchestrator 2012 with PowerShell
Now is the time to flip things around and send it back. So would you believe me if I told you this is actually very easy to do?
Take a look at our tiny script from previously. Let’s pretend it has its own information that needs to be sent TO Orchestrator.
So here we have three pieces of data in a Windows PowerShell script. We’d like to make this information accessible to the next activity in the runbook.
To do this, you need to use the Published Data option. Click it to open it.
Click Add to open the Published Data Wizard (Hey, does this wizard have a cool wand? No?)
In the Name text box, type the Name to be used on the data bus if someone needs to subscribe to it. It can be a different name than your Windows PowerShell object, but it can also be the same.
Orchestrator (at the time of this post) supports three types of data: Date/Time, Integer, and String. In the drop-down list, select String.
In the Variable Name text box, type in the name of the Windows PowerShell variable you want to publish to the data bus.
In our earlier example, if we were trying to publish the object called $Important, we would fill out the Published Data as follows:
We just need to remove the $ from the name of the object. The name is also not case sensitive. As I mentioned earlier, the Name does NOT have to be the same as the Windows PowerShell object name. I could also publish it as FlyingRubberChicken or EvenMoreImportantDataThanTheFirstTime.
All this means is that if I access Published Data from that particular activity, and the names don’t match, I should have something in my documentation to draw a reference to the new name. Personally, I try not to change the names, but you can if you like or need to. Click OK whenever you’re done.
If you were publishing the Date/Time data, it would look like this:
Not so tricky is it?
In this case, I decided to publish all of the data. It turned out like this when I was done and clicked the Published Data tab:
When I click Finish and check the runbook in, I can access this data from other Orchestrator activities as I normally would with any other Published Data.
In the case of this particular script, I published all of the values. But I can publish as little or as much as I want. As you can tell, it is a manual process, and you must enter each object to be published individually.
So now we’ve seen how to get information IN and OUT of Windows PowerShell and Orchestrator. But is there anything else we need to worry about? Anything we can or cannot do?
Check back tomorrow and we’ll talk more…
I invite you to follow the Scripting Guys on Twitter and Facebook. If you have any questions, send email to scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.
Sean Kearney, Honorary Scripting Guy
Windows PowerShell MVP