<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>PowerTip: Check to See if a Command Completes Properly</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/26/powertip-check-to-see-if-a-command-completes-properly.aspx</link><description>Learn how to check for proper completion of a Windows PowerShell command.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: PowerTip: Check to See if a Command Completes Properly</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/26/powertip-check-to-see-if-a-command-completes-properly.aspx#3516591</link><pubDate>Tue, 28 Aug 2012 01:20:54 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3516591</guid><dc:creator>Ed Wilson</dc:creator><description>&lt;p&gt;@Walid Toumi, great addition. Thank you your comment.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3516591" width="1" height="1"&gt;</description></item><item><title>re: PowerTip: Check to See if a Command Completes Properly</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/26/powertip-check-to-see-if-a-command-completes-properly.aspx#3516337</link><pubDate>Sun, 26 Aug 2012 19:55:31 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3516337</guid><dc:creator>Walid Toumi</dc:creator><description>&lt;p&gt;hi,&lt;/p&gt;
&lt;p&gt;Thanks Ed, here is also:&lt;/p&gt;
&lt;p&gt;c. $LastExitCode&lt;/p&gt;
&lt;p&gt;PS II&amp;gt; replace&lt;/p&gt;
&lt;p&gt;PS II&amp;gt; $LastExitCode&lt;/p&gt;
&lt;p&gt;11&lt;/p&gt;
&lt;p&gt;d. ErrorVariable parameter&lt;/p&gt;
&lt;p&gt;PS II&amp;gt; get-item 1:\xoo -ErrorAction 0 -ErrorVariable foo&lt;/p&gt;
&lt;p&gt;PS II&amp;gt; if($foo) { write-error &amp;quot;error !!&amp;quot; }&lt;/p&gt;
&lt;p&gt;e. try catch finally&lt;/p&gt;
&lt;p&gt;PS II&amp;gt; try {&lt;/p&gt;
&lt;p&gt; &amp;nbsp;$PreferenceErrorAction=$ErrorActionPreference&lt;/p&gt;
&lt;p&gt; &amp;nbsp;$ErrorActionPreference = &amp;#39;stop&amp;#39;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;command....&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;catch {&lt;/p&gt;
&lt;p&gt; &amp;nbsp;$_&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;finally {&lt;/p&gt;
&lt;p&gt; $ErrorActionPreference = $PreferenceErrorAction&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3516337" width="1" height="1"&gt;</description></item></channel></rss>