<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://powershell.com/cs/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>Power Tips</title><link>http://powershell.com/cs/blogs/tips/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2008.5 (Build: 30929.2835)</generator><item><title>Type Accelerators</title><link>http://powershell.com/cs/blogs/tips/archive/2010/09/02/type-accelerators.aspx</link><pubDate>Thu, 02 Sep 2010 13:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7487</guid><dc:creator>ps1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://powershell.com/cs/blogs/tips/rsscomments.aspx?PostID=7487</wfw:commentRss><comments>http://powershell.com/cs/blogs/tips/archive/2010/09/02/type-accelerators.aspx#comments</comments><description>&lt;p&gt;PowerShell has a few shortcuts for popular .NET types like [WMI], [ADSI] or [Int]. You should read the FullName property if you&amp;#39;d like to know the underlying full type name:&lt;/p&gt;
&lt;div class="pscode"&gt;[&lt;span class="optional"&gt;WMI&lt;/span&gt;].&lt;span class="method"&gt;FullName&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Type+Accelerators+with+%23Powershell+http%3A%2F%2Fbit.ly%2FcN9qHU"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Type+Accelerators+with+%23Powershell+http%3A%2F%2Fbit.ly%2FcN9qHU"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=7487" width="1" height="1"&gt;</description></item><item><title>Comparing Versions</title><link>http://powershell.com/cs/blogs/tips/archive/2010/09/01/comparing-versions.aspx</link><pubDate>Wed, 01 Sep 2010 13:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7486</guid><dc:creator>ps1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://powershell.com/cs/blogs/tips/rsscomments.aspx?PostID=7486</wfw:commentRss><comments>http://powershell.com/cs/blogs/tips/archive/2010/09/01/comparing-versions.aspx#comments</comments><description>&lt;p&gt;When you compare version strings, PowerShell will use alphanumeric algorithms, which may lead to confusing results:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="string"&gt;&amp;#39;3.4.22.12&amp;#39;&lt;/span&gt; &lt;span class="op"&gt;-gt&lt;/span&gt; &lt;span class="string"&gt;&amp;#39;22.1.4.34&amp;#39;&lt;/span&gt;&lt;br /&gt;True&lt;/div&gt;
&lt;p&gt;You should convert the strings to a System.Version type to compare version strings right. In fact, converting the left hand value is enough because PowerShell automatically converts the right hand value to the same type:&lt;/p&gt;
&lt;div class="pscode"&gt;[&lt;span class="namespace"&gt;System.Version&lt;/span&gt;] &lt;span class="string"&gt;&amp;#39;3.4.22.12&amp;#39;&lt;/span&gt; &lt;span class="op"&gt;-gt&lt;/span&gt; &lt;span class="string"&gt;&amp;#39;22.1.4.34&amp;#39;&lt;/span&gt;&lt;br /&gt;False&lt;/div&gt;
&lt;p&gt;&lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Comparing+Versions+with+%23Powershell+http%3A%2F%2Fbit.ly%2FbrMtSK"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Comparing+Versions+with+%23Powershell+http%3A%2F%2Fbit.ly%2FbrMtSK"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=7486" width="1" height="1"&gt;</description></item><item><title>View Object Inheritance</title><link>http://powershell.com/cs/blogs/tips/archive/2010/08/31/view-object-inheritance.aspx</link><pubDate>Tue, 31 Aug 2010 13:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7485</guid><dc:creator>ps1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://powershell.com/cs/blogs/tips/rsscomments.aspx?PostID=7485</wfw:commentRss><comments>http://powershell.com/cs/blogs/tips/archive/2010/08/31/view-object-inheritance.aspx#comments</comments><description>&lt;p&gt;A hidden object property called &amp;quot;PSTypeNames&amp;quot; will tell you the object type as well as the inherited chain:&lt;/p&gt;
&lt;div class="pscode"&gt;(&lt;span class="verbnoun"&gt;Get-WMIObject&lt;/span&gt; Win32_BIOS).&lt;span class="method"&gt;PSTypeNames&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;In contrast to GetType(), this property will work for all objects, including COM objects. The most specific type is always found at the beginning of that array:&lt;/p&gt;
&lt;div class="pscode"&gt;(&lt;span class="verbnoun"&gt;Get-WMIObject&lt;/span&gt; Win32_BIOS).&lt;span class="method"&gt;PSTypeNames&lt;/span&gt;[0]&lt;/div&gt;
&lt;p&gt;&lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+View+Object+Inheritance+with+%23Powershell+http%3A%2F%2Fbit.ly%2Fcy1ZgP"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+View+Object+Inheritance+with+%23Powershell+http%3A%2F%2Fbit.ly%2Fcy1ZgP"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=7485" width="1" height="1"&gt;</description></item><item><title>Using Scripts to Validate Input</title><link>http://powershell.com/cs/blogs/tips/archive/2010/08/30/using-scripts-to-validate-input.aspx</link><pubDate>Mon, 30 Aug 2010 13:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7484</guid><dc:creator>ps1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://powershell.com/cs/blogs/tips/rsscomments.aspx?PostID=7484</wfw:commentRss><comments>http://powershell.com/cs/blogs/tips/archive/2010/08/30/using-scripts-to-validate-input.aspx#comments</comments><description>&lt;p&gt;For tricky validation checks, you should use arbitrary PowerShell code to validate. The function Copy-OldFiles will only accept files (no folders) and those that are older (in days) than specified in -Days:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="keyword"&gt;function&lt;/span&gt; &lt;span class="verbnoun"&gt;Copy-OldFiles&lt;/span&gt; {&lt;br /&gt;&lt;span class="keyword"&gt;param&lt;/span&gt;(&lt;br /&gt;&lt;span class="var"&gt;$Days&lt;/span&gt;&lt;span class="op"&gt;=&lt;/span&gt;30,&lt;br /&gt;[Parameter(ValueFromPipeline&lt;span class="op"&gt;=&lt;/span&gt;&lt;span class="var"&gt;$true&lt;/span&gt;)]&lt;br /&gt;[&lt;span class="namespace"&gt;System.IO.FileInfo&lt;/span&gt;]&lt;br /&gt;[ValidateScript({ (&lt;span class="verbnoun"&gt;New-TimeSpan&lt;/span&gt; &lt;span class="var"&gt;$_&lt;/span&gt;.&lt;span class="method"&gt;LastWriteTime&lt;/span&gt;).&lt;span class="method"&gt;Days&lt;/span&gt; &lt;span class="op"&gt;-gt&lt;/span&gt; &lt;span class="var"&gt;$Days&lt;/span&gt; })]&lt;br /&gt;&lt;span class="var"&gt;$FileObject&lt;/span&gt;&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;process {&lt;br /&gt;&lt;span class="string"&gt;&amp;quot;Archiving file {0} (Age {1})...&amp;quot;&lt;/span&gt; &lt;span class="op"&gt;-f&lt;/span&gt; &lt;span class="var"&gt;$FileObject&lt;/span&gt;.&lt;span class="method"&gt;FullName&lt;/span&gt;, (&lt;span class="verbnoun"&gt;New-TimeSpan&lt;/span&gt; &lt;span class="var"&gt;$_&lt;/span&gt;.&lt;span class="method"&gt;LastWriteTime&lt;/span&gt;).&lt;span class="method"&gt;Days&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;/div&gt;
&lt;p&gt;The validation script will then check whether the file submitted via the pipeline is older than specified in -Days. If not, the file is rejected. And this is how you could archive all log files in your Windows folder that are older than 40 days:&lt;/p&gt;
&lt;div class="pscode"&gt;dir &lt;span class="var"&gt;$env:windir&lt;/span&gt; &lt;span class="op"&gt;-&lt;/span&gt;&lt;span class="keyword"&gt;Filter&lt;/span&gt; &lt;span class="op"&gt;*&lt;/span&gt;.&lt;span class="method"&gt;log&lt;/span&gt; | &lt;span class="verbnoun"&gt;Copy-OldFiles&lt;/span&gt; &lt;span class="modifier"&gt;-Days&lt;/span&gt; 40 &lt;span class="modifier"&gt;-ErrorAction&lt;/span&gt; SilentlyContinue&lt;/div&gt;
&lt;p&gt;&lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+View+Object+Inheritance+with+%23Powershell+http%3A%2F%2Fbit.ly%2Fd1Hm7h"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+View+Object+Inheritance+with+%23Powershell+http%3A%2F%2Fbit.ly%2Fd1Hm7h"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=7484" width="1" height="1"&gt;</description></item><item><title>Restrict Input to Numeric Ranges</title><link>http://powershell.com/cs/blogs/tips/archive/2010/08/27/restrict-input-to-numeric-ranges.aspx</link><pubDate>Fri, 27 Aug 2010 13:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7444</guid><dc:creator>ps1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://powershell.com/cs/blogs/tips/rsscomments.aspx?PostID=7444</wfw:commentRss><comments>http://powershell.com/cs/blogs/tips/archive/2010/08/27/restrict-input-to-numeric-ranges.aspx#comments</comments><description>&lt;p&gt;Let&amp;#39;s say you&amp;#39;d like to set the PowerShell console cursor size. This size must be a number between 0 and 100. The following template will validate that the user cannot specify an argument outside the allowed range:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="keyword"&gt;function&lt;/span&gt; &lt;span class="verbnoun"&gt;Set-CursorSize&lt;/span&gt; {&lt;br /&gt;&lt;span class="keyword"&gt;param&lt;/span&gt;(&lt;br /&gt;[ValidateRange(1,100)]&lt;br /&gt;[&lt;span class="datatype"&gt;Int&lt;/span&gt;]&lt;br /&gt;&lt;span class="var"&gt;$Percent&lt;/span&gt;&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span class="var"&gt;$Host&lt;/span&gt;.&lt;span class="namespace"&gt;UI.RawUI.CursorSize&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="var"&gt;$Percent&lt;/span&gt;&lt;br /&gt;}&lt;/div&gt;
&lt;p&gt;&lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Restrict+Input+to+Numeric+Ranges+with+%23Powershell+http%3A%2F%2Fbit.ly%2F9ZYWAr"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Restrict+Input+to+Numeric+Ranges+with+%23Powershell+http%3A%2F%2Fbit.ly%2F9ZYWAr"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=7444" width="1" height="1"&gt;</description></item><item><title>Converting Object Types</title><link>http://powershell.com/cs/blogs/tips/archive/2010/08/26/converting-object-types.aspx</link><pubDate>Thu, 26 Aug 2010 13:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7443</guid><dc:creator>ps1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://powershell.com/cs/blogs/tips/rsscomments.aspx?PostID=7443</wfw:commentRss><comments>http://powershell.com/cs/blogs/tips/archive/2010/08/26/converting-object-types.aspx#comments</comments><description>&lt;p&gt;Once you know the name of an object type, you can use that type for conversion. The next line converts a string into a date-time type:&lt;/p&gt;
&lt;div class="pscode"&gt;[&lt;span class="optional"&gt;DateTime&lt;/span&gt;] &lt;span class="string"&gt;&amp;#39;4.5.2010&amp;#39;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;You should note that conversion uses the culture-neutral date format which happens to be the U.S. format. If you need to use your local date format, you should use the Parse() method found inside the DateTime type:&lt;/p&gt;
&lt;div class="pscode"&gt;[&lt;span class="optional"&gt;DateTime&lt;/span&gt;]::&lt;span class="method"&gt;Parse&lt;/span&gt;(&lt;span class="string"&gt;&amp;#39;4.5.2010&amp;#39;&lt;/span&gt;)&lt;/div&gt;
&lt;p&gt;&lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Converting+Object+Types+with+%23Powershellhttp%3A%2F%2Fbit.ly%2FbMVoWJ"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Converting+Object+Types+with+%23Powershellhttp%3A%2F%2Fbit.ly%2FbMVoWJ"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=7443" width="1" height="1"&gt;</description></item><item><title>Finding Object Types with Powershell</title><link>http://powershell.com/cs/blogs/tips/archive/2010/08/25/finding-object-types-with-powershell.aspx</link><pubDate>Wed, 25 Aug 2010 13:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7442</guid><dc:creator>ps1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://powershell.com/cs/blogs/tips/rsscomments.aspx?PostID=7442</wfw:commentRss><comments>http://powershell.com/cs/blogs/tips/archive/2010/08/25/finding-object-types-with-powershell.aspx#comments</comments><description>&lt;p&gt;Anything in PowerShell is an object. You can use GetType() to get the object type:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="string"&gt;&amp;#39;Hallo&amp;#39;&lt;/span&gt;.&lt;span class="method"&gt;GetType&lt;/span&gt;().&lt;span class="method"&gt;FullName&lt;/span&gt;&lt;br /&gt;(4).&lt;span class="method"&gt;GetType&lt;/span&gt;().&lt;span class="method"&gt;FullName&lt;/span&gt;&lt;br /&gt;(2.6).&lt;span class="method"&gt;GetType&lt;/span&gt;().&lt;span class="method"&gt;FullName&lt;/span&gt;&lt;br /&gt;(&lt;span class="verbnoun"&gt;Get-Date&lt;/span&gt;).&lt;span class="method"&gt;GetType&lt;/span&gt;().&lt;span class="method"&gt;FullName&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Finding+Object+Types+with+%23Powershell+http%3A%2F%2Fbit.ly%2FaAwvqz"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Finding+Object+Types+with+%23Powershell+http%3A%2F%2Fbit.ly%2FaAwvqz"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=7442" width="1" height="1"&gt;</description></item><item><title>Validate Input Using Regular Expressions</title><link>http://powershell.com/cs/blogs/tips/archive/2010/08/24/validate-input-using-regular-expressions.aspx</link><pubDate>Tue, 24 Aug 2010 13:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7441</guid><dc:creator>ps1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://powershell.com/cs/blogs/tips/rsscomments.aspx?PostID=7441</wfw:commentRss><comments>http://powershell.com/cs/blogs/tips/archive/2010/08/24/validate-input-using-regular-expressions.aspx#comments</comments><description>&lt;p&gt;Function parameters can be validated using standard regular expressions. For example, the next template function accepts only valid Knowledge Base article numbers beginning with &amp;quot;KB&amp;quot; and a six- digit number:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="keyword"&gt;function&lt;/span&gt; &lt;span class="verbnoun"&gt;Get-KnowledgeBaseArticle&lt;/span&gt; {&lt;br /&gt;&lt;span class="keyword"&gt;param&lt;/span&gt;(&lt;br /&gt;[ValidatePattern(&lt;span class="string"&gt;&amp;#39;^KB\d{6}$&amp;#39;&lt;/span&gt;)]&lt;br /&gt;[&lt;span class="datatype"&gt;String&lt;/span&gt;]&lt;br /&gt;&lt;span class="var"&gt;$KB&lt;/span&gt;&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span class="string"&gt;&amp;quot;You entered Knowledgebase ID $KB&amp;quot;&lt;/span&gt;&lt;br /&gt;}&lt;/div&gt;
&lt;p&gt;&lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Validate+Input+Using+Regular+Expressions+with+%23Powershell+http%3A%2F%2Fbit.ly%2F9Y44OU"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Validate+Input+Using+Regular+Expressions+with+%23Powershell+http%3A%2F%2Fbit.ly%2F9Y44OU"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=7441" width="1" height="1"&gt;</description></item><item><title>Limiting String Input Length</title><link>http://powershell.com/cs/blogs/tips/archive/2010/08/23/limiting-string-input-length.aspx</link><pubDate>Mon, 23 Aug 2010 13:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7440</guid><dc:creator>ps1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://powershell.com/cs/blogs/tips/rsscomments.aspx?PostID=7440</wfw:commentRss><comments>http://powershell.com/cs/blogs/tips/archive/2010/08/23/limiting-string-input-length.aspx#comments</comments><description>&lt;p&gt;If a function parameter should receive a string of a given length only, you should use the following validation attribute. In the example, it limits filenames to eight characters:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="keyword"&gt;function&lt;/span&gt; &lt;span class="verbnoun"&gt;Get-FileName&lt;/span&gt; {&lt;br /&gt;&lt;span class="keyword"&gt;param&lt;/span&gt;(&lt;br /&gt;[ValidateLength(1,8)]&lt;br /&gt;[&lt;span class="datatype"&gt;String&lt;/span&gt;]&lt;br /&gt;&lt;span class="var"&gt;$FileName&lt;/span&gt;&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span class="string"&gt;&amp;quot;Your filename {0} is {1} chars long&amp;quot;&lt;/span&gt; &lt;span class="op"&gt;-f&lt;/span&gt; &lt;span class="var"&gt;$FileName&lt;/span&gt;, &lt;span class="var"&gt;$FileName&lt;/span&gt;.&lt;span class="method"&gt;Length&lt;/span&gt;&lt;br /&gt;}&lt;/div&gt;
&lt;p&gt;&lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Limiting+String+Input+Length+with+%23Powershell+http%3A%2F%2Fbit.ly%2FaLuc9z"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Limiting+String+Input+Length+with+%23Powershell+http%3A%2F%2Fbit.ly%2FaLuc9z"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=7440" width="1" height="1"&gt;</description></item><item><title>Limiting Number of Arguments</title><link>http://powershell.com/cs/blogs/tips/archive/2010/08/20/limiting-number-of-arguments.aspx</link><pubDate>Fri, 20 Aug 2010 13:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7423</guid><dc:creator>ps1</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://powershell.com/cs/blogs/tips/rsscomments.aspx?PostID=7423</wfw:commentRss><comments>http://powershell.com/cs/blogs/tips/archive/2010/08/20/limiting-number-of-arguments.aspx#comments</comments><description>&lt;p&gt;Function parameters can receive multiple values when they accept arrays. You should use this template to limit the number of values acceptable:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="keyword"&gt;function&lt;/span&gt; &lt;span class="verbnoun"&gt;Add-Users&lt;/span&gt; {&lt;br /&gt;&lt;span class="keyword"&gt;param&lt;/span&gt;(&lt;br /&gt;[ValidateCount(1,3)]&lt;br /&gt;[&lt;span class="datatype"&gt;String&lt;/span&gt;[]]&lt;br /&gt;&lt;span class="var"&gt;$UserName&lt;/span&gt; &lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span class="var"&gt;$UserName&lt;/span&gt; &lt;span class="op"&gt;-&lt;/span&gt;&lt;span class="verbnoun"&gt;ForEach-Object&lt;/span&gt; { &lt;span class="string"&gt;&amp;quot;Adding $_&amp;quot;&lt;/span&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;/div&gt;
&lt;p&gt;Here, Add-Users will accept one to three user names as a comma-separated list. If you specify more or less, you will get an error message.&lt;/p&gt;
&lt;p&gt;&lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Limiting+Number+of+Arguments+with+%23Powershell+http%3A%2F%2Fbit.ly%2FagRDF5"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Limiting+Number+of+Arguments+with+%23Powershell+http%3A%2F%2Fbit.ly%2FagRDF5"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=7423" width="1" height="1"&gt;</description></item><item><title>Defining Alias Properties</title><link>http://powershell.com/cs/blogs/tips/archive/2010/08/19/defining-alias-properties.aspx</link><pubDate>Thu, 19 Aug 2010 13:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7422</guid><dc:creator>ps1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://powershell.com/cs/blogs/tips/rsscomments.aspx?PostID=7422</wfw:commentRss><comments>http://powershell.com/cs/blogs/tips/archive/2010/08/19/defining-alias-properties.aspx#comments</comments><description>&lt;p&gt;Your functions can have properties with built-in alias names. The user can then either use the descriptive &amp;quot;long&amp;quot; name or its short and convenient alias name:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="keyword"&gt;function&lt;/span&gt; &lt;span class="verbnoun"&gt;Get-BIOSInfo&lt;/span&gt; {&lt;br /&gt;&lt;span class="keyword"&gt;param&lt;/span&gt;(&lt;br /&gt;[Alias(&lt;span class="string"&gt;&amp;quot;CN&amp;quot;&lt;/span&gt;)]&lt;br /&gt;&lt;span class="var"&gt;$ComputerName&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="string"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span class="verbnoun"&gt;Get-WmiObject&lt;/span&gt; Win32_BIOS &lt;span class="modifier"&gt;-ComputerName&lt;/span&gt; &lt;span class="var"&gt;$computername&lt;/span&gt;&lt;br /&gt;}&lt;/div&gt;
&lt;p&gt;You should either use -ComputerName or its alias -CN to retrieve BIOS information from a remote system..&lt;/p&gt;
&lt;p&gt;&lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Defining+Alias+Properties+with+%23Powershell+http%3A%2F%2Fbit.ly%2F9jsv9U"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Defining+Alias+Properties+with+%23Powershell+http%3A%2F%2Fbit.ly%2F9jsv9U"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=7422" width="1" height="1"&gt;</description></item><item><title>Validate Set of Inputs</title><link>http://powershell.com/cs/blogs/tips/archive/2010/08/18/validate-set-of-inputs.aspx</link><pubDate>Wed, 18 Aug 2010 13:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7421</guid><dc:creator>ps1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://powershell.com/cs/blogs/tips/rsscomments.aspx?PostID=7421</wfw:commentRss><comments>http://powershell.com/cs/blogs/tips/archive/2010/08/18/validate-set-of-inputs.aspx#comments</comments><description>&lt;p&gt;If you need to limit a function parameter to only a set of allowed choices, you should use the next example:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="keyword"&gt;function&lt;/span&gt; Get&lt;span class="op"&gt;-&lt;/span&gt;24hEventLogEntries {&lt;br /&gt;&lt;span class="keyword"&gt;param&lt;/span&gt;(&lt;br /&gt;[&lt;span class="datatype"&gt;String&lt;/span&gt;]&lt;br /&gt;[ValidateSet(&lt;span class="string"&gt;&amp;#39;System&amp;#39;&lt;/span&gt;,&lt;span class="string"&gt;&amp;#39;Application&amp;#39;&lt;/span&gt;)]&lt;br /&gt;&lt;span class="var"&gt;$LogName&lt;/span&gt;&lt;span class="op"&gt;=&lt;/span&gt;&lt;span class="string"&gt;&amp;#39;System&amp;#39;&lt;/span&gt;,&lt;br /&gt;&lt;br /&gt;[&lt;span class="datatype"&gt;String&lt;/span&gt;]&lt;br /&gt;[ValidateSet(&lt;span class="string"&gt;&amp;#39;Error&amp;#39;&lt;/span&gt;,&lt;span class="string"&gt;&amp;#39;Warning&amp;#39;&lt;/span&gt;,&lt;span class="string"&gt;&amp;#39;Information&amp;#39;&lt;/span&gt;)]&lt;br /&gt;&lt;span class="var"&gt;$EntryType&lt;/span&gt;&lt;span class="op"&gt;=&lt;/span&gt;&lt;span class="string"&gt;&amp;#39;Error&amp;#39;&lt;/span&gt;&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span class="verbnoun"&gt;Get-EventLog&lt;/span&gt; &lt;span class="modifier"&gt;-LogName&lt;/span&gt; &lt;span class="var"&gt;$LogName&lt;/span&gt; &lt;span class="modifier"&gt;-EntryType&lt;/span&gt; &lt;span class="var"&gt;$EntryType&lt;/span&gt; &lt;span class="modifier"&gt;-After&lt;/span&gt; ((&lt;span class="verbnoun"&gt;Get-Date&lt;/span&gt;).&lt;span class="method"&gt;AddDays&lt;/span&gt;(&lt;span class="op"&gt;-&lt;/span&gt;1))&lt;br /&gt;&lt;br /&gt;}&lt;/div&gt;
&lt;p&gt;You can use Get-24hEventLogEntries to retrieve events written in the past 24 hours. The user can choose to see the &amp;#39;system&amp;#39; or the &amp;#39;application&amp;#39; log. EntryType is limited to &amp;#39;Error,&amp;#39; &amp;#39;Warning,&amp;#39; or &amp;#39;Information.&amp;#39;&lt;/p&gt;
&lt;p&gt;&lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Validate+Set+of+Inputs+with+%23Powershell+http%3A%2F%2Fbit.ly%2FajutP5"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Validate+Set+of+Inputs+with+%23Powershell+http%3A%2F%2Fbit.ly%2FajutP5"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=7421" width="1" height="1"&gt;</description></item><item><title>Finding Cmdlets With a Given Parameter</title><link>http://powershell.com/cs/blogs/tips/archive/2010/08/17/finding-cmdlets-by-name-is-easy.aspx</link><pubDate>Tue, 17 Aug 2010 14:09:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7419</guid><dc:creator>ps1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://powershell.com/cs/blogs/tips/rsscomments.aspx?PostID=7419</wfw:commentRss><comments>http://powershell.com/cs/blogs/tips/archive/2010/08/17/finding-cmdlets-by-name-is-easy.aspx#comments</comments><description>&lt;p&gt;Finding cmdlets by name is easy:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="verbnoun"&gt;Get-Command&lt;/span&gt; &lt;span class="op"&gt;*&lt;/span&gt;service&lt;span class="op"&gt;*&lt;/span&gt; &lt;span class="modifier"&gt;-commandType&lt;/span&gt; Cmdlet&lt;/div&gt;
&lt;p&gt;But how can you list all cmdlets that support a given parameter? If you&amp;rsquo;d like to see all cmdlets with a -List parameter?&lt;/p&gt;
&lt;p&gt;The easiest way is to use Get-Help with the parameter -parameter:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="verbnoun"&gt;Get-Help&lt;/span&gt; &lt;span class="op"&gt;*&lt;/span&gt; &lt;span class="modifier"&gt;-parameter&lt;/span&gt; list&lt;/div&gt;
&lt;p&gt;Or, you can use Get-Command and filter the result by parameter. You&amp;rsquo;ll need a custom filter to accomplish this:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="keyword"&gt;filter&lt;/span&gt; &lt;span class="verbnoun"&gt;Contains-Parameter&lt;/span&gt; {&lt;br /&gt;&lt;span class="keyword"&gt;param&lt;/span&gt;(&lt;span class="var"&gt;$name&lt;/span&gt;)&lt;br /&gt;&lt;span class="var"&gt;$number&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; @(&lt;span class="var"&gt;$_&lt;/span&gt; | &lt;span class="op"&gt;%&lt;/span&gt; { &lt;span class="var"&gt;$_&lt;/span&gt;.&lt;span class="method"&gt;ParameterSets&lt;/span&gt; | &lt;span class="op"&gt;%&lt;/span&gt; { &lt;span class="var"&gt;$_&lt;/span&gt;.&lt;span class="method"&gt;Parameters&lt;/span&gt; | ? { &lt;span class="var"&gt;$_&lt;/span&gt;.&lt;span class="method"&gt;Name&lt;/span&gt; &lt;span class="op"&gt;-eq&lt;/span&gt; &lt;span class="var"&gt;$name&lt;/span&gt;}}}).&lt;span class="method"&gt;Count&lt;/span&gt;&lt;br /&gt;&lt;span class="keyword"&gt;if&lt;/span&gt; (&lt;span class="var"&gt;$number&lt;/span&gt; &lt;span class="op"&gt;-gt&lt;/span&gt; 0) {&lt;br /&gt;&lt;span class="var"&gt;$_&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;/div&gt;
&lt;p&gt;This filter allows only those to pass the pipeline that supports the given parameter. Here is how you use the filter:&lt;/p&gt;
&lt;div class="pscode"&gt;&lt;span class="verbnoun"&gt;Get-Command&lt;/span&gt; | &lt;span class="verbnoun"&gt;Contains-Parameter&lt;/span&gt; &lt;span class="string"&gt;&amp;#39;list&amp;#39;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Finding+Cmdlets+With+a+Given+Parameter+with+%23Powershell+http%3A%2F%2Fbit.ly%2FbTcXqa"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Finding+Cmdlets+With+a+Given+Parameter+with+%23Powershell+http%3A%2F%2Fbit.ly%2FbTcXqa"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=7419" width="1" height="1"&gt;</description></item><item><title>Removing All Internet Explorer Cookies</title><link>http://powershell.com/cs/blogs/tips/archive/2010/08/16/removing-all-internet-explorer-cookies.aspx</link><pubDate>Mon, 16 Aug 2010 13:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7350</guid><dc:creator>ps1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://powershell.com/cs/blogs/tips/rsscomments.aspx?PostID=7350</wfw:commentRss><comments>http://powershell.com/cs/blogs/tips/archive/2010/08/16/removing-all-internet-explorer-cookies.aspx#comments</comments><description>&lt;p&gt;You&amp;#39;d probably like to regularly clean your machine and remove all cookies set by Web sites you may have visited? Here is how:&lt;/p&gt;
&lt;div class="pscode"&gt;Dir ([&lt;span class="optional"&gt;Environment&lt;/span&gt;]::&lt;span class="method"&gt;GetFolderPath&lt;/span&gt;(&lt;span class="string"&gt;&amp;quot;Cookies&amp;quot;&lt;/span&gt;)) | del &lt;span class="modifier"&gt;-whatif&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;You will want to make sure you remove the -whatif to actually delete the cookie files.&lt;/p&gt;
&lt;p&gt;&lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Removing+All+Internet+Explorer+Cookies+with+%23Powershell+http%3A%2F%2Fbit.ly%2FadTQc5"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Removing+All+Internet+Explorer+Cookies+with+%23Powershell+http%3A%2F%2Fbit.ly%2FadTQc5"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=7350" width="1" height="1"&gt;</description></item><item><title>Listing Internet Explorer Cookies</title><link>http://powershell.com/cs/blogs/tips/archive/2010/08/13/listing-internet-explorer-cookies.aspx</link><pubDate>Fri, 13 Aug 2010 13:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:7349</guid><dc:creator>ps1</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://powershell.com/cs/blogs/tips/rsscomments.aspx?PostID=7349</wfw:commentRss><comments>http://powershell.com/cs/blogs/tips/archive/2010/08/13/listing-internet-explorer-cookies.aspx#comments</comments><description>&lt;p&gt;Have you ever wanted to find out who stored your information while you were surfing the Web? Check out your cookies folder:&lt;/p&gt;
&lt;div class="pscode"&gt;Dir ([&lt;span class="optional"&gt;Environment&lt;/span&gt;]::&lt;span class="method"&gt;GetFolderPath&lt;/span&gt;(&lt;span class="string"&gt;&amp;quot;Cookies&amp;quot;&lt;/span&gt;))&lt;/div&gt;
&lt;p&gt;You should try this to open that folder in your Explorer:&lt;/p&gt;
&lt;div class="pscode"&gt;Explorer ([&lt;span class="optional"&gt;Environment&lt;/span&gt;]::&lt;span class="method"&gt;GetFolderPath&lt;/span&gt;(&lt;span class="string"&gt;&amp;quot;Cookies&amp;quot;&lt;/span&gt;))&lt;/div&gt;
&lt;p&gt;And if you&amp;#39;d like, you could also select cookies based on content. The next line lists all cookies that contain the word &amp;quot;prefbin:&amp;rdquo;&lt;/p&gt;
&lt;div class="pscode"&gt;Dir ([&lt;span class="optional"&gt;Environment&lt;/span&gt;]::&lt;span class="method"&gt;GetFolderPath&lt;/span&gt;(&lt;span class="string"&gt;&amp;quot;Cookies&amp;quot;&lt;/span&gt;)) | &lt;span class="verbnoun"&gt;Select-String&lt;/span&gt; prefbin &lt;span class="modifier"&gt;-List&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Listing+Internet+Explorer+Cookies+with+%23Powershell+http%3A%2F%2Fbit.ly%2FcBb8Jc"&gt;&lt;img src="http://powershell.com/cs/Themes/powershell/images/ps/twitter_32x32.png" alt="Twitter This Tip!" style="vertical-align:middle;border:0px;" /&gt;&lt;/a&gt; &lt;a target="twitter" href="http://twitter.com/home/?status=RT+%40PowerTip+Listing+Internet+Explorer+Cookies+with+%23Powershell+http%3A%2F%2Fbit.ly%2FcBb8Jc"&gt;ReTweet this Tip!&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://powershell.com/cs/aggbug.aspx?PostID=7349" width="1" height="1"&gt;</description></item></channel></rss>