{"id":8341,"date":"2012-08-10T11:59:00","date_gmt":"2012-08-10T11:59:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2012\/08\/10\/powertip-specifying-powershell-error-actions\/"},"modified":"2012-08-10T11:59:00","modified_gmt":"2012-08-10T11:59:00","slug":"powertip-specifying-powershell-error-actions","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-specifying-powershell-error-actions\/","title":{"rendered":"PowerTip: Specifying PowerShell Error Actions"},"content":{"rendered":"<p><strong>Summary<\/strong>:&nbsp;Specify Windows PowerShell error actions.\n<b>Question<\/b>: Which command when typed at the beginning of a script will cause Windows PowerShell to ignore errors and continue executing the code?<\/p>\n<p style=\"padding-left: 30px\"><b>Answer<\/b>: $erroractionpreference=SilentlyContinue\n<b>Question<\/b>: How can I ignore errors for a single command instead of for the entire script?<\/p>\n<p style=\"padding-left: 30px\"><b>Answer<\/b>: Use the&nbsp;<b>ErrorAction<\/b><i>&nbsp;<\/i>parameter and specify one of the following values:&nbsp;<b>SilentlyContinue<\/b>,&nbsp;.\n<b>Question<\/b>: That is a lot of typing. Is there an easier way to specify the&nbsp;<b>ErrorAction<\/b><i>&nbsp;<\/i>for a single command?<\/p>\n<p style=\"padding-left: 30px\"><b>Answer<\/b>: Yes. You can use the parameter alias&nbsp;<b>EA<\/b><i>&nbsp;<\/i>and use a number value for the action. For example,&nbsp;<b>0<\/b>&nbsp;is&nbsp;<b>SilentlyContinue, 1 is&nbsp;<b>Stop<\/b>,<\/b><b>&nbsp;2 is <b>Continue<\/b>, 3 is&nbsp;<b>Inquire<\/b>, or 4 is <b>Ignore.<\/b><\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary:&nbsp;Specify Windows PowerShell error actions. Question: Which command when typed at the beginning of a script will cause Windows PowerShell to ignore errors and continue executing the code? Answer: $erroractionpreference=SilentlyContinue Question: How can I ignore errors for a single command instead of for the entire script? Answer: Use the&nbsp;ErrorAction&nbsp;parameter and specify one of the following [&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":[356,3,45],"class_list":["post-8341","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-powertip","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary:&nbsp;Specify Windows PowerShell error actions. Question: Which command when typed at the beginning of a script will cause Windows PowerShell to ignore errors and continue executing the code? Answer: $erroractionpreference=SilentlyContinue Question: How can I ignore errors for a single command instead of for the entire script? Answer: Use the&nbsp;ErrorAction&nbsp;parameter and specify one of the following [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/8341","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=8341"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/8341\/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=8341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=8341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=8341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}