{"id":80845,"date":"2016-11-18T11:59:14","date_gmt":"2016-11-18T19:59:14","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/?p=80845"},"modified":"2019-02-18T09:10:20","modified_gmt":"2019-02-18T16:10:20","slug":"powertip-return-a-status-code-to-linux-from-powershell","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-return-a-status-code-to-linux-from-powershell\/","title":{"rendered":"PowerTip: Return a status code to Linux from PowerShell"},"content":{"rendered":"<p><strong>Summary<\/strong>: Pass a result code back to a calling Linux environment from Open Source PowerShell.<\/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\" \/> How can I pass a numeric value back to a calling Bash Shell to indicate an error?<\/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\" \/> Just simply supply the <strong>EXIT<\/strong> command and a numeric value at the point where the error is flagged. For example, the following code is a PowerShell script that returns a value of 76 if the script does not match the value of <code>$Value<\/code>.<\/p>\n<p style=\"padding-left: 90px\"><code>If ($Value -eq \u2018Something Good\u2019)\n{\nWrite-Output \u2018It\u2019s Good, it\u2019s very Good\u2019\n}\nElse\n{\nExist 76\n}<\/code><\/p>\n<p style=\"padding-left: 30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\" alt=\"The Doctor\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Pass a result code back to a calling Linux environment from Open Source PowerShell. How can I pass a numeric value back to a calling Bash Shell to indicate an error? Just simply supply the EXIT command and a numeric value at the point where the error is flagged. For example, the following code [&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":[568,639,641],"tags":[56,356,154,45],"class_list":["post-80845","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hey-scripting-guy","category-powertip","category-windows-powershell","tag-guest-blogger","tag-powertip","tag-sean-kearney","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Pass a result code back to a calling Linux environment from Open Source PowerShell. How can I pass a numeric value back to a calling Bash Shell to indicate an error? Just simply supply the EXIT command and a numeric value at the point where the error is flagged. For example, the following code [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/80845","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=80845"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/80845\/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=80845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=80845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=80845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}