{"id":17832,"date":"2008-12-23T07:55:07","date_gmt":"2008-12-23T15:55:07","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/powershell\/?p=17832"},"modified":"2019-06-07T07:56:30","modified_gmt":"2019-06-07T15:56:30","slug":"advanced-functions-and-test-leapyear-ps1","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/advanced-functions-and-test-leapyear-ps1\/","title":{"rendered":"Advanced Functions and Test-LeapYear.ps1"},"content":{"rendered":"<p><P>Welcome to CTP3!&nbsp; There are just an amazing amount of really important features in V2 but the one I want everyone to start using ASAP is Advanced Functions.&nbsp; In CTP2 we called this cmdlets.&nbsp; We dropped that term in favor of taking the idea of a FUNCTION and just making it more and more capable.&nbsp; It is a bit of a misnomer in that you can have an &#8220;Advanced function&#8221; by just adding a single line to your script.&nbsp; You&#8217;ll be amazed what that single line gives you; but we&#8217;ll explore that later.&nbsp; This entry recaps where we are with functions and then begins to give you a feel for some of the great benefits you have with advanced functions.&nbsp; There is a LOT more to advanced functions than I&#8217;ll show you here.&nbsp; You get an incredible amount for just a tiny amount of additional code. <\/P>\n<P>Going forward, I think that the community should\/will establish the norm that the functions you share with other people and blog about should be Advanced Functions.<\/P>\n<P>This post is a bit of mouthful but I encourage you to follow it and get on the Advanced Function bandwagon.&nbsp; This is a gamechanger.&nbsp; Alternatively, you can just start messing with them.&nbsp; I&#8217;ve attached a ZIP file containing both Test-LeapYear.ps1 and a demo-test-leapyear.txt file that you can run using my <A href=\"http:\/\/blogs.msdn.com\/powershell\/archive\/2007\/03\/06\/improved-start-demo-script.aspx\" mce_href=\"http:\/\/blogs.msdn.com\/powershell\/archive\/2007\/03\/06\/improved-start-demo-script.aspx\">Start-Demo script.<\/A>&nbsp;&nbsp; Either way &#8211; invest and you will be rewarded!<\/P>\n<P>Jeffrey Snover [MSFT] <BR>Windows Management Partner Architect <BR>Visit the Windows PowerShell Team blog at:&nbsp;&nbsp;&nbsp; <A href=\"http:\/\/blogs.msdn.com\/PowerShell\" mce_href=\"http:\/\/blogs.msdn.com\/PowerShell\">http:\/\/blogs.msdn.com\/PowerShell<\/A> <BR>Visit the Windows PowerShell ScriptCenter at:&nbsp; <A href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx\" mce_href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx\">http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx<\/A><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#ff8000><FONT color=#000000><\/FONT><\/FONT><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#ff8000><FONT color=#000000>[0]PS&gt; #Functions can be simple<\/FONT> <BR><\/FONT>[1]PS&gt; function Test-LeapYear {[DateTime]::IsLeapYear($args[0])} <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>[2]PS&gt; Test-LeapYear 2008 <BR>True <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#ff8000><FONT color=#000000><\/FONT><\/FONT><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#ff8000><FONT color=#000000><\/FONT><\/FONT><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#ff8000><FONT color=#000000>[3]PS&gt; # But there are issues with simplicity <BR>[4]PS&gt; # The obvious one is that you have readability issues. <BR>[5]PS&gt; # What is $args[0] anyway? <BR>[6]PS&gt; # Also you have no type checking on the parameter.<\/FONT> <BR><\/FONT>[7]PS&gt; Test-LeapYear ThisYear <BR><FONT color=#ff0000>Start-Demo : Cannot convert argument &#8220;0&#8221;, with value: &#8220;ThisYear&#8221;, for &#8220;IsLe <BR>apYear&#8221; to type &#8220;System.Int32&#8221;: &#8220;Cannot convert value &#8220;ThisYear&#8221; to type &#8220;S <BR>ystem.Int32&#8243;. Error: &#8220;Input string was not in a correct format.&#8221;&#8221; <BR>At line:1 char:11 <BR>+ start-demo &lt;&lt;&lt;&lt;&nbsp; .\\demo-Test-LeapYear.ps1 <BR>&nbsp;&nbsp;&nbsp; + CategoryInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : NotSpecified: (:) [Write-Error], WriteErrorE <BR>&nbsp;&nbsp; xception <BR>&nbsp;&nbsp;&nbsp; + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExce <BR>&nbsp;&nbsp; ption,Start-Demo <\/FONT><\/FONT><\/P>\n<P><FONT face=Consolas color=#ff0000 size=2><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#ff8000><FONT color=#000000>[8]PS&gt; # There is no checking on the # of arguments<\/FONT> <BR><\/FONT>[9]PS&gt; Test-LeapYear 2008 2009 2010 2011 <BR>True <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000><\/FONT><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000><\/FONT><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000>[10]PS&gt; ############################################## <BR>[11]PS&gt; # In V1 you could remedy these issues with Named parameters:<\/FONT> <BR>[12]PS&gt; function Test-LeapYear {param([Int]$Year=[DateTime]::Now.Year)&nbsp; [Dat <BR>eTime]::IsLeapYear($Year)} <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000><\/FONT><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000>[13]PS&gt; # Now you use variables whose names are self-documenting <BR>[14]PS&gt; # You get the same functions you got before<\/FONT> <BR>[15]PS&gt; Test-LeapYear 2008 <BR>True <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000><\/FONT><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000><\/FONT><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000>[16]PS&gt; # But now you also get NAMED parameters which makes it <BR>[17]PS&gt; # even more self-documenting<\/FONT> <BR>[18]PS&gt; Test-LeapYear -Year 2008 <BR>True <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000><\/FONT><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000><\/FONT><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000>[19]PS&gt; # You now have type checking on the parameter.<\/FONT> <BR>[20]PS&gt; Test-LeapYear ThisYear <BR><FONT color=#ff0000>Start-Demo : Cannot process argument transformation on parameter &#8216;Year&#8217;. Ca <BR>nnot convert value &#8220;ThisYear&#8221; to type &#8220;System.Int32&#8221;. Error: &#8220;Input string <BR>was not in a correct format.&#8221; <BR>At line:1 char:11 <BR>+ start-demo &lt;&lt;&lt;&lt;&nbsp; .\\demo-Test-LeapYear.ps1 <BR>&nbsp;&nbsp;&nbsp; + CategoryInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : NotSpecified: (:) [Write-Error], WriteErrorE <BR>&nbsp;&nbsp; xception <BR>&nbsp;&nbsp;&nbsp; + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExce <BR>&nbsp;&nbsp; ption,Start-Demo <\/FONT><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000><\/FONT><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000><\/FONT><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000>[21]PS&gt; # But there is still no checking on the # of arguments<\/FONT> <BR>[22]PS&gt; Test-LeapYear 2008 2009 2010 2011 <BR>True <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000>[23]PS&gt; # Of course you were on your own for help as well. <BR><\/FONT><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000><\/FONT><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000><\/FONT><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000>&nbsp;<\/P><\/FONT><\/FONT>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000>[24]PS&gt; ########################################## <BR>[25]PS&gt; # <BR>[26]PS&gt; # But now you have Advanced Functions: <BR><\/FONT>[27]PS&gt; Get-Content .\\Test-LeapYear.ps1 <BR>&lt;# <BR>.Synopsis <BR>&nbsp;&nbsp;&nbsp; Determines whether a year is a leapyear or not. <BR>.Description <BR>&nbsp;&nbsp;&nbsp; This is a simple function to demonstrate the capabilities of PowerShell <BR>&nbsp;&nbsp;&nbsp; V2 Advanced Functions by telling whether a year is a leap year or not. <BR>.Parameter Year <BR>&nbsp;&nbsp;&nbsp; Which year would you like tested? <BR>.Example <BR>&nbsp;&nbsp;&nbsp; PS&gt; Test-LeapYear 2008 <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>.ReturnValue <BR>&nbsp;&nbsp;&nbsp; [Boolean] <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>.Link <BR>&nbsp;&nbsp;&nbsp; about_functions <BR>&nbsp;&nbsp;&nbsp; about_functions_advanced <BR>&nbsp;&nbsp;&nbsp; about_functions_advanced_methods <BR>&nbsp;&nbsp;&nbsp; about_functions_advanced_parameters <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>.Notes <BR>NAME:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Verb-Noun <BR>AUTHOR:&nbsp;&nbsp;&nbsp; NTDEV\\jsnover <BR>LASTEDIT:&nbsp; 12\/22\/2008 20:39:07 <BR>#Requires -Version 2.0 <BR>#&gt; <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>param( <BR>[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)] <BR>[Int]$Year <BR>) <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>Process <BR>{ <BR>&nbsp;&nbsp;&nbsp; [DateTime]::IsLeapYear($Year) <BR>}#Process <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><\/FONT><\/P>\n<P><FONT face=Consolas color=#000000 size=2><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#000000 size=2><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#000000 size=2>[28]PS&gt; # You have all the stuff you had before but now look what you get: <BR><\/FONT><FONT face=Consolas color=#0000ff size=2><FONT color=#000000>[29]PS&gt; # It ensures that you send it the right number of parameters: <BR><\/FONT>[30]PS&gt; .\\Test-LeapYear 2008 2009 2010 2011 <BR><FONT color=#ff0000>Start-Demo : A positional parameter cannot be found that accepts argument &#8216; <BR>2009&#8242;. <BR>At line:1 char:11 <BR>+ start-demo &lt;&lt;&lt;&lt;&nbsp; .\\demo-Test-LeapYear.ps1 <BR>&nbsp;&nbsp;&nbsp; + CategoryInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : NotSpecified: (:) [Write-Error], WriteErrorE <BR>&nbsp;&nbsp; xception <BR>&nbsp;&nbsp;&nbsp; + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExce <BR>&nbsp;&nbsp; ption,Start-Demo<\/FONT> <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000><\/FONT><\/FONT><\/P>\n<P><FONT face=Consolas color=#000000 size=2><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000><\/FONT><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000>[31]PS&gt; # It supports pipelining<\/FONT> <BR><\/FONT><FONT face=Consolas color=#0000ff size=2>[32]PS&gt; 2008,2009,2010,2011 | .\\Test-LeapYear <BR>True <BR>False <BR>False <BR>False<\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000><\/FONT><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000>[33]PS&gt; # I can&#8217;t demo it year but it also supports Tab-Completion of paramete <BR>rnames <BR>[34]PS&gt; # Best of all, it supports HELP <BR><\/FONT>[35]PS&gt; Get-Help .\\Test-LeapYear -full <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>NAME <BR>&nbsp;&nbsp;&nbsp; C:\\temp\\Test-LeapYear.ps1 <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>SYNOPSIS <BR>&nbsp;&nbsp;&nbsp; Determines whether a year is a leapyear or not. <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>SYNTAX <BR>&nbsp;&nbsp;&nbsp; C:\\temp\\Test-LeapYear.ps1 [-Year] [&lt;Int32&gt;] [-Verbose] [-Debug] [-Error <BR>&nbsp;&nbsp;&nbsp; Action [&lt;ActionPreference&gt;]] [-WarningAction [&lt;ActionPreference&gt;]] [-Er <BR>&nbsp;&nbsp;&nbsp; rorVariable [&lt;String&gt;]] [-WarningVariable [&lt;String&gt;]] [-OutVariable [&lt;S <BR>&nbsp;&nbsp;&nbsp; tring&gt;]] [-OutBuffer [&lt;Int32&gt;]] [&lt;CommonParameters&gt;] <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>DETAILED DESCRIPTION <BR>&nbsp;&nbsp;&nbsp; This is a simple function to demonstrate the capabilities of PowerShell <BR>&nbsp;&nbsp;&nbsp; V2 Advanced Functions by telling whether a year is a leap year or not. <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>PARAMETERS <BR>&nbsp;&nbsp;&nbsp; -Year <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Which year would you like tested? <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Required?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; true <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Position?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Default value <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Accept pipeline input?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; true (ByValue) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Accept wildcard characters? <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>&nbsp;&nbsp;&nbsp; &lt;CommonParameters&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This cmdlet supports the common parameters: -Verbose, -Debug, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -OutBuffer and -OutVariable. For more information, type, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;get-help about_commonparameters&#8221;. <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>INPUT TYPE <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>RETURN TYPE <BR>&nbsp;&nbsp;&nbsp; [Boolean] <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>NOTES <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NAME:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Verb-Noun <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AUTHOR:&nbsp;&nbsp;&nbsp; NTDEV\\jsnover <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LASTEDIT:&nbsp; 12\/22\/2008 20:39:07 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #Requires -Version 2.0 <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; EXAMPLE 1 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>&nbsp;&nbsp;&nbsp; PS&gt; Test-LeapYear 2008 <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>RELATED LINKS <BR>&nbsp;&nbsp;&nbsp; about_functions <BR>&nbsp;&nbsp;&nbsp; about_functions_advanced <BR>&nbsp;&nbsp;&nbsp; about_functions_advanced_methods <BR>&nbsp;&nbsp;&nbsp; about_functions_advanced_parameters <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000><\/FONT><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000>[36]PS&gt; # Notice that while we only declared one parameter, <BR>[37]PS&gt; # it actually has 9! <BR>[38]PS&gt; # These are provided by the PowerShell engine. <BR><\/FONT>[39]PS&gt; (Get-Command .\\Test-LeapYear.ps1).Parameters <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>Key&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Value <BR>&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8211; <BR>Year&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Management.Automation.Param&#8230; <BR>Verbose&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Management.Automation.Param&#8230; <BR>Debug&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Management.Automation.Param&#8230; <BR>ErrorAction&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Management.Automation.Param&#8230; <BR>WarningAction&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Management.Automation.Param&#8230; <BR>ErrorVariable&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Management.Automation.Param&#8230; <BR>WarningVariable&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Management.Automation.Param&#8230; <BR>OutVariable&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Management.Automation.Param&#8230; <BR>OutBuffer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Management.Automation.Param&#8230; <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000><\/FONT><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#0000ff size=2><FONT color=#000000>[40]PS&gt; # Let&#8217;s see them in action <BR><\/FONT>[41]PS&gt; 2008,2009,2010 |.\\Test-LeapYear.ps1 -OutVariable Results <BR>True <BR>False <BR>False <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>[42]PS&gt; $results <BR>True <BR>False <BR>False <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#0000ff size=2><\/FONT>&nbsp;<\/P>\n<P><FONT face=Consolas color=#0000ff size=2>[43]PS&gt; 2008,&#8221;Burp&#8221;,2010 |.\\Test-LeapYear.ps1 -ErrorAction Stop <BR>True <BR><FONT color=#ff0000>Start-Demo : Command execution stopped because the preference variable &#8220;Err <BR>orActionPreference&#8221; or common parameter is set to Stop: The input object ca <BR>nnot be bound to any parameters for the command either because the command <BR>does not take pipeline input or the input and its properties do not match a <BR>ny of the parameters that take pipeline input. <BR>At line:1 char:11 <BR>+ start-demo &lt;&lt;&lt;&lt;&nbsp; .\\demo-Test-LeapYear.ps1 <BR>&nbsp;&nbsp;&nbsp; + CategoryInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : NotSpecified: (:) [Write-Error], WriteErrorE <BR>&nbsp;&nbsp; xception <BR>&nbsp;&nbsp;&nbsp; + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExce <BR>&nbsp;&nbsp; ption,Start-Demo <\/FONT><\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>[44]PS&gt; 2008,&#8221;Burp&#8221;,2010 |.\\Test-LeapYear.ps1 -ErrorAction SilentlyContinue <\/FONT><\/P>\n<P><FONT face=Consolas color=#0000ff size=2>True&nbsp;<BR>&nbsp;False<\/FONT><\/P><\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Components.PostAttachments\/00\/09\/24\/92\/84\/Test-LeapYear.zip\" original-url=\"http:\/\/blogs.msdn.com\/cfs-file.ashx\/__key\/communityserver-components-postattachments\/00-09-24-92-84\/Test_2D00_LeapYear.zip\">Test-LeapYear.zip<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to CTP3!&nbsp; There are just an amazing amount of really important features in V2 but the one I want everyone to start using ASAP is Advanced Functions.&nbsp; In CTP2 we called this cmdlets.&nbsp; We dropped that term in favor of taking the idea of a FUNCTION and just making it more and more capable.&nbsp; [&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":[97,137,328],"class_list":["post-17832","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-advanced-functions","tag-ctp3","tag-test-leapyear"],"acf":[],"blog_post_summary":"<p>Welcome to CTP3!&nbsp; There are just an amazing amount of really important features in V2 but the one I want everyone to start using ASAP is Advanced Functions.&nbsp; In CTP2 we called this cmdlets.&nbsp; We dropped that term in favor of taking the idea of a FUNCTION and just making it more and more capable.&nbsp; [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17832","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=17832"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17832\/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=17832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=17832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=17832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}