{"id":6401,"date":"2008-04-09T22:44:18","date_gmt":"2008-04-09T22:44:18","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2008\/04\/09\/erroraction-update\/"},"modified":"2019-02-18T13:16:04","modified_gmt":"2019-02-18T20:16:04","slug":"erroraction-update","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/erroraction-update\/","title":{"rendered":"-ErrorAction update"},"content":{"rendered":"<p>Responding to&#160; my blog entry on -ErrorAction <a href=\"http:\/\/blogs.msdn.com\/powershell\/archive\/2008\/03\/29\/erroraction-silentlycontinue-ea-0.aspx\">HERE<\/a>,&#160; Jon Newman reminded me that the reason we didn&#8217;t use the term IGNORE for -ErrorAction was that we don&#8217;t really ignore the error.&#160; We still record it in $ERROR.<\/p>\n<p>He also reminded me that I should have talked about $ErrorActionPreference.&#160; This variable defines the action that will occur if the user does NOT specify what to do on the commandline.&#160; Check it out:<\/p>\n<p><font face=\"Courier New\" size=\"2\">PS&gt;<strong>$ErrorActionPreference<\/strong>      <br \/>Continue      <br \/>PS&gt;<strong>Stop-Process 13,23       <br \/><\/strong><font color=\"#ff0000\">Stop-Process : Cannot find a process with the process identifier 13.       <br \/>At line:1 char:13        <br \/>+ Stop-Process &lt;&lt;&lt;&lt;&#160; 13,23        <br \/>Stop-Process : Cannot find a process with the process identifier 23.        <br \/>At line:1 char:13        <br \/>+ Stop-Process &lt;&lt;&lt;&lt;&#160; 13,23        <br \/><\/font>PS&gt;<strong>$ErrorActionPreference =&quot;SilentlyContinue&quot;<\/strong>      <br \/>PS&gt;<strong>Stop-Process 13,23<\/strong>      <br \/>PS&gt;<strong>$ErrorActionPreference =&quot;Stop&quot;<\/strong>      <br \/>PS&gt;<strong>Stop-Process 13,23       <br \/><\/strong><font color=\"#ff0000\">Stop-Process : Command execution stopped because the preference variable &quot;ErrorActionPreference&quot; or common parameter i       <br \/> set to Stop: Cannot find a process with the process identifier 13.        <br \/>At line:1 char:13        <br \/>+ Stop-Process &lt;&lt;&lt;&lt;&#160; 13,23        <br \/><\/font>PS&gt;<strong>$ErrorActionPreference =&quot;Inquire&quot;<\/strong>      <br \/>PS&gt;<strong>Stop-Process 13,23<\/strong> <\/font><\/p>\n<p><font face=\"Courier New\" size=\"2\">Confirm     <br \/>Cannot find a process with the process identifier 13.      <br \/>[Y] Yes&#160; [A] Yes to All&#160; [H] Halt Command&#160; [S] Suspend&#160; [?] Help (default is &quot;Y&quot;): h      <br \/><font color=\"#ff0000\">Stop-Process : Command execution stopped because the user selected the Halt option.       <br \/>At line:1 char:13        <br \/>+ Stop-Process &lt;&lt;&lt;&lt;&#160; 13,23<\/font><\/font><\/p>\n<p>Enjoy!<\/p>\n<p>Jeffrey Snover [MSFT]   <br \/>Windows Management Partner Architect    <br \/>Visit the Windows PowerShell Team blog at:&#160;&#160;&#160; <a href=\"http:\/\/blogs.msdn.com\/PowerShell\">http:\/\/blogs.msdn.com\/PowerShell<\/a>    <br \/>Visit the Windows PowerShell ScriptCenter at:&#160; <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx\">http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Responding to&#160; my blog entry on -ErrorAction HERE,&#160; Jon Newman reminded me that the reason we didn&#8217;t use the term IGNORE for -ErrorAction was that we don&#8217;t really ignore the error.&#160; We still record it in $ERROR. He also reminded me that I should have talked about $ErrorActionPreference.&#160; This variable defines the action that will [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6401","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>Responding to&#160; my blog entry on -ErrorAction HERE,&#160; Jon Newman reminded me that the reason we didn&#8217;t use the term IGNORE for -ErrorAction was that we don&#8217;t really ignore the error.&#160; We still record it in $ERROR. He also reminded me that I should have talked about $ErrorActionPreference.&#160; This variable defines the action that will [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/6401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=6401"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/6401\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=6401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=6401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=6401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}