<?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>Simplify Your PowerShell Script with Parameter Validation</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/15/simplify-your-powershell-script-with-parameter-validation.aspx</link><description>Learn how to simplify your Windows PowerShell Script by using parameter validation attribute.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Simplify Your PowerShell Script with Parameter Validation</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/15/simplify-your-powershell-script-with-parameter-validation.aspx#3579129</link><pubDate>Sun, 16 Jun 2013 09:55:35 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3579129</guid><dc:creator>i.biswajith</dc:creator><description>&lt;p&gt;Awesome for param.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3579129" width="1" height="1"&gt;</description></item><item><title>re: Simplify Your PowerShell Script with Parameter Validation</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/15/simplify-your-powershell-script-with-parameter-validation.aspx#3550615</link><pubDate>Wed, 06 Feb 2013 05:36:31 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3550615</guid><dc:creator>Craig Lussier</dc:creator><description>&lt;p&gt;Great post - your notes came in handy today :)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3550615" width="1" height="1"&gt;</description></item><item><title>re: Simplify Your PowerShell Script with Parameter Validation</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/15/simplify-your-powershell-script-with-parameter-validation.aspx#3527827</link><pubDate>Sun, 21 Oct 2012 20:27:36 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3527827</guid><dc:creator>jrv</dc:creator><description>&lt;p&gt;#requires -version 2.0&lt;/p&gt;
&lt;p&gt;function t{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; param(&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;[ValidateRange(21,65)]$x&lt;/p&gt;
&lt;p&gt; &amp;nbsp; )&lt;/p&gt;
&lt;p&gt;$x&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;t 3 # fails&lt;/p&gt;
&lt;p&gt;t 21 # succeeds&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3527827" width="1" height="1"&gt;</description></item><item><title>re: Simplify Your PowerShell Script with Parameter Validation</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/15/simplify-your-powershell-script-with-parameter-validation.aspx#3527815</link><pubDate>Sun, 21 Oct 2012 19:43:24 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3527815</guid><dc:creator>Panayot</dc:creator><description>&lt;p&gt;Is that example for PS2? As am geting error if I use [ValidateRange(21,65)]&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3527815" width="1" height="1"&gt;</description></item><item><title>re: Simplify Your PowerShell Script with Parameter Validation</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/15/simplify-your-powershell-script-with-parameter-validation.aspx#3484349</link><pubDate>Fri, 02 Mar 2012 20:55:30 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3484349</guid><dc:creator>jrv</dc:creator><description>&lt;p&gt;function Test-Msg{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; Param(&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[Parameter(&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Mandatory=$true,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HelpMessage=&amp;#39;Count of things in the world&amp;#39;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;)][string]$count &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;# body here&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Test-Msg # and follow instructions on the screen&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3484349" width="1" height="1"&gt;</description></item><item><title>re: Simplify Your PowerShell Script with Parameter Validation</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/15/simplify-your-powershell-script-with-parameter-validation.aspx#3484344</link><pubDate>Fri, 02 Mar 2012 20:29:52 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3484344</guid><dc:creator>st9912345</dc:creator><description>&lt;p&gt;This is great. &amp;nbsp;Can you additional add in text to decribe what the parameters are for?&lt;/p&gt;
&lt;p&gt;ie.&lt;/p&gt;
&lt;p&gt;0 - extracts data for people data&lt;/p&gt;
&lt;p&gt;1 - extracts data for vendor data&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3484344" width="1" height="1"&gt;</description></item><item><title>re: Simplify Your PowerShell Script with Parameter Validation</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/15/simplify-your-powershell-script-with-parameter-validation.aspx#3445198</link><pubDate>Thu, 04 Aug 2011 20:50:20 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3445198</guid><dc:creator>Ed Wilson</dc:creator><description>&lt;p&gt;@JRV Error variable is a good one. Great suggestion. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3445198" width="1" height="1"&gt;</description></item><item><title>re: Simplify Your PowerShell Script with Parameter Validation</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/15/simplify-your-powershell-script-with-parameter-validation.aspx#3445043</link><pubDate>Thu, 04 Aug 2011 09:30:52 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3445043</guid><dc:creator>jrv</dc:creator><description>&lt;p&gt;Don&amp;#39;t forget ErrorVariable!&lt;/p&gt;
&lt;p&gt;help common&lt;/p&gt;
&lt;p&gt;# list non-existent folder causing an error&lt;/p&gt;
&lt;p&gt;Get-Content xxxx -ea SilentlyContinue -ev +MyError&lt;/p&gt;
&lt;p&gt;$MyError&lt;/p&gt;
&lt;p&gt;Look Ma! No red lines anymore. &amp;nbsp;My errors have turned white.&lt;/p&gt;
&lt;p&gt;Good Luck and have fun.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3445043" width="1" height="1"&gt;</description></item><item><title>re: Simplify Your PowerShell Script with Parameter Validation</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/15/simplify-your-powershell-script-with-parameter-validation.aspx#3444998</link><pubDate>Thu, 04 Aug 2011 04:00:53 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3444998</guid><dc:creator>Ed Wilson</dc:creator><description>&lt;p&gt;@Will Steele You can also set -erroractionpreference (parameter alias -EA) on each PowerShell cmdlet. You also have the Try / Catch / Finally construction that can be used for structured error handling. Look at the PowerShell / Error Handling tags on the Hey Scripting Guy blog for some articles around these topics.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3444998" width="1" height="1"&gt;</description></item><item><title>re: Simplify Your PowerShell Script with Parameter Validation</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/15/simplify-your-powershell-script-with-parameter-validation.aspx#3444987</link><pubDate>Thu, 04 Aug 2011 03:20:44 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3444987</guid><dc:creator>Will Steele</dc:creator><description>&lt;p&gt;Aside from altering the $ErrorActionPreference is there a way to handle errors that results from failed validation? &amp;nbsp;For instance, if I have a non-terminating error, how would I be able to continue processing and just note the issue to an ErrorVariable?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3444987" width="1" height="1"&gt;</description></item></channel></rss>