{"id":2895,"date":"2013-09-10T00:01:00","date_gmt":"2013-09-10T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/09\/10\/systems-center-2012-orchestrator-and-powershell-part-2\/"},"modified":"2013-09-10T00:01:00","modified_gmt":"2013-09-10T00:01:00","slug":"systems-center-2012-orchestrator-and-powershell-part-2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/systems-center-2012-orchestrator-and-powershell-part-2\/","title":{"rendered":"Systems Center 2012 Orchestrator and PowerShell: Part 2"},"content":{"rendered":"<p><strong>Summary<\/strong>: Make data from a Windows PowerShell script in System Center&nbsp;2012 Orchestrator accessible on the data bus.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/>&nbsp;Hey, Scripting Guy!<\/p>\n<p>We love using Windows PowerShell with System Center&nbsp;2012 Orchestrator, but we&rsquo;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?<\/p>\n<p>&mdash;TS<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/>&nbsp;Hello TS,<\/p>\n<p>Honorary Scripting Guy, Sean Kearney here. I&rsquo;m continuing to fill in for Ed this week.<\/p>\n<p>So last time we saw how to get data IN to Windows PowerShell from Orchestrator:<\/p>\n<p style=\"padding-left: 30px\"><a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2013\/09\/09\/access-data-from-orchestrator-2012-with-powershell.aspx\" target=\"_blank\">Access Data from Orchestrator 2012 with PowerShell<\/a><\/p>\n<p>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?<\/p>\n<p>Take a look at our tiny script from previously. Let&rsquo;s pretend it has its own information that needs to be sent TO Orchestrator.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1033.01.png\"><img decoding=\"async\" title=\"Image of menu\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1033.01.png\" alt=\"Image of menu\" \/><\/a><\/p>\n<p>So here we have three pieces of data in a Windows PowerShell script. We&rsquo;d like to make this information accessible to the next activity in the runbook.<\/p>\n<p>To do this, you need to use the <strong>Published Data<\/strong> option. Click it to open it.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0537.02.png\"><img decoding=\"async\" title=\"Image of menu\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0537.02.png\" alt=\"Image of menu\" \/><\/a><\/p>\n<p>Click <strong>Add<\/strong> to open the Published Data Wizard (Hey, does this wizard have a cool wand? No?)<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6237.03.png\"><img decoding=\"async\" title=\"Image of menu\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6237.03.png\" alt=\"Image of menu\" \/><\/a><\/p>\n<p>In the <strong>Name<\/strong> 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.<\/p>\n<p>Orchestrator (at the time of this post) supports three types of data: Date\/Time, Integer, and String. In the drop-down list, select <strong>String<\/strong>.<\/p>\n<p>In the <strong>Variable Name<\/strong> text box, type in the name of the Windows PowerShell variable you want to publish to the data bus.<\/p>\n<p>In our earlier example, if we were trying to publish the object called <strong>$Important<\/strong>, we would fill out the Published Data as follows:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0285.04.png\"><img decoding=\"async\" title=\"Image of menu\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0285.04.png\" alt=\"Image of menu\" width=\"350\" height=\"178\" \/><\/a><\/p>\n<p>We just need to remove the <strong>$<\/strong> from the name of the object. The name is also not case sensitive. As I mentioned earlier, the <strong>Name<\/strong> does NOT have to be the same as the Windows PowerShell object name. I could also publish it as FlyingRubberChicken or EvenMoreImportantDataThanTheFirstTime.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3010.05.png\"><img decoding=\"async\" title=\"Image of menu\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3010.05.png\" alt=\"Image of menu\" \/><\/a><\/p>\n<p>All this means is that if I access Published Data from that particular activity, and the names don&rsquo;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 <strong>OK<\/strong> whenever you&rsquo;re done.<\/p>\n<p>If you were publishing the Date\/Time data, it would look like this:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2451.06.png\"><img decoding=\"async\" title=\"Image of menu\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2451.06.png\" alt=\"Image of menu\" \/><\/a><\/p>\n<p>Not so tricky is it?<\/p>\n<p>In this case, I decided to publish all of the data. It turned out like this when I was done and clicked the <strong>Published Data<\/strong> tab:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5342.07.png\"><img decoding=\"async\" title=\"Image of menu\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5342.07.png\" alt=\"Image of menu\" \/><\/a><\/p>\n<p>When I click <strong>Finish<\/strong> and check the runbook in, I can access this data from other Orchestrator activities as I normally would with any other Published Data.<\/p>\n<p>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.<\/p>\n<p>So now we&rsquo;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?<\/p>\n<p>Check back tomorrow and we&rsquo;ll talk more&hellip;<\/p>\n<p>I invite you to follow the Scripting Guys on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><strong>Sean Kearney, Honorary Scripting Guy<br \/> Windows PowerShell MVP<\/strong>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Make data from a Windows PowerShell script in System Center&nbsp;2012 Orchestrator accessible on the data bus. &nbsp;Hey, Scripting Guy! We love using Windows PowerShell with System Center&nbsp;2012 Orchestrator, but we&rsquo;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 [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[56,154,61,45],"class_list":["post-2895","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-guest-blogger","tag-sean-kearney","tag-weekend-scripter","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Make data from a Windows PowerShell script in System Center&nbsp;2012 Orchestrator accessible on the data bus. &nbsp;Hey, Scripting Guy! We love using Windows PowerShell with System Center&nbsp;2012 Orchestrator, but we&rsquo;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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2895","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=2895"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2895\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=2895"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=2895"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=2895"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}