{"id":2881,"date":"2013-09-11T11:59:00","date_gmt":"2013-09-11T11:59:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/09\/11\/powertip-trapping-variables-within-a-powershell-script-in-orchestrator\/"},"modified":"2013-09-11T11:59:00","modified_gmt":"2013-09-11T11:59:00","slug":"powertip-trapping-variables-within-a-powershell-script-in-orchestrator","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-trapping-variables-within-a-powershell-script-in-orchestrator\/","title":{"rendered":"PowerTip: Trapping Variables Within a PowerShell Script in Orchestrator"},"content":{"rendered":"<p><strong>Summary<\/strong>: Get data from Windows Powershell in Orchestrator for debugging.<\/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;Is there an easy way to troubleshoot a Windows PowerShell script in Orchestrator so I can see if the data is&nbsp;<strong>$Null<\/strong>&nbsp;or is the right type?<\/p>\n<p style=\"padding-left: 30px\"><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;Leverage the&nbsp;<strong>Export-Clixml<\/strong>&nbsp;cmdlet within the script against the object in question:<\/p>\n<p style=\"padding-left: 120px\">$SomethingNotWorking=GET-CONTENT (C:\\somefile.txt)<\/p>\n<p style=\"padding-left: 120px\">$SomethingNotWorking | EXPORT-CLIXML C:\\debug\\something.txt<\/p>\n<p style=\"padding-left: 60px\">Then in Windows PowerShell, rebuild the variable to examine it outside of the script:<\/p>\n<p style=\"padding-left: 120px\">[xml]$SomethingNotWorking=(GET-CONTENT C:\\debug\\something.txt)<\/p>\n<p style=\"padding-left: 120px\">$SomethingNotWorking | GET-MEMBER<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\" alt=\"\" border=\"0\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Get data from Windows Powershell in Orchestrator for debugging. &nbsp;Is there an easy way to troubleshoot a Windows PowerShell script in Orchestrator so I can see if the data is&nbsp;$Null&nbsp;or is the right type? &nbsp;Leverage the&nbsp;Export-Clixml&nbsp;cmdlet within the script against the object in question: $SomethingNotWorking=GET-CONTENT (C:\\somefile.txt) $SomethingNotWorking | EXPORT-CLIXML C:\\debug\\something.txt Then in Windows PowerShell, [&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,356,154,45],"class_list":["post-2881","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-guest-blogger","tag-powertip","tag-sean-kearney","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Get data from Windows Powershell in Orchestrator for debugging. &nbsp;Is there an easy way to troubleshoot a Windows PowerShell script in Orchestrator so I can see if the data is&nbsp;$Null&nbsp;or is the right type? &nbsp;Leverage the&nbsp;Export-Clixml&nbsp;cmdlet within the script against the object in question: $SomethingNotWorking=GET-CONTENT (C:\\somefile.txt) $SomethingNotWorking | EXPORT-CLIXML C:\\debug\\something.txt Then in Windows PowerShell, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2881","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=2881"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2881\/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=2881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=2881"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=2881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}