<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cupfighter.net &#187; cmdlet</title>
	<atom:link href="http://www.cupfighter.net/index.php/tag/cmdlet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cupfighter.net</link>
	<description>A blog by Schuberg Philis colleagues</description>
	<lastBuildDate>Thu, 09 Feb 2012 14:27:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>PowerShell: Controlling Cmdlet parameters</title>
		<link>http://www.cupfighter.net/index.php/2009/06/powershell-controlling-cmdlet-parameters/</link>
		<comments>http://www.cupfighter.net/index.php/2009/06/powershell-controlling-cmdlet-parameters/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 13:52:19 +0000</pubDate>
		<dc:creator>Hans van Veen</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[cmdlet]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Schuberg Philis]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.cupfighter.net/?p=167</guid>
		<description><![CDATA[PowerShell allows for inline parameter control for some of its cmdlet parameters. Based upon commandline and/or inputfile content you might want to turm some of the cmdlet parameters on or off. For example: scripts manipulating files will often use the Get-ChildItem cmdlet in combination with the -recurse parameter, but not allways the subfolder files are required. Instead [...]]]></description>
			<content:encoded><![CDATA[<p>PowerShell allows for inline parameter control for some of its cmdlet parameters. Based upon commandline and/or inputfile content you might want to turm some of the cmdlet parameters on or off.</p>
<p>For example: scripts manipulating files will often use the Get-ChildItem cmdlet in combination with the -recurse parameter, but not allways the subfolder files are required. Instead off having multiple Get-ChildItem commandlines (each with their own set of parameters) a single line might be possible.</p>
<p>The following examples use the Get-ChildItem cmdlet to show what I mean.</p>
<p>The command in figure below will display all *.tmp files in the current folder and its subfolders.</p>
<p><img class="alignnone size-full wp-image-170" title="image11" src="http://www.cupfighter.net/wp-content/uploads/2009/06/image11.bmp" alt="Get-ChildItem without parameter control" width="552" height="226" /></p>
<p>By extending -recurse with :$false recursive lookup will be turned off.</p>
<p><img class="alignnone size-full wp-image-173" title="image2" src="http://www.cupfighter.net/wp-content/uploads/2009/06/image2.bmp" alt="Get-ChildItem with recures lookup turned off" width="557" height="213" /></p>
<p>On the otherhand, replacing $false with $true will turn recursive lookup on again.</p>
<p>So using a boolean variable we can turn recursive lookup on or off from within the script (-recurse:$RecurseOnOff). And of course this method also works for other parameters.</p>
<p><img class="alignnone size-full wp-image-174" title="image3" src="http://www.cupfighter.net/wp-content/uploads/2009/06/image3.bmp" alt="Get-ChildItem with multiple controls" width="556" height="238" /></p>
<p>And it does get stranger&#8230;.. in some occasions you can also reverse the default action of a parameter. Hence the following figure.</p>
<p><img class="alignnone size-full wp-image-175" title="image4" src="http://www.cupfighter.net/wp-content/uploads/2009/06/image4.bmp" alt="Reverse parameter action" width="560" height="195" /></p>
<p>The 1st command will show all files with exception of the *.tmp files. By appending :$false to -exclude, we turn -exclude into -include as demonstrated by the 2nd command.</p>
<p>This form of parameter manipulation offers a scala of possibilities. Using script parameters to control cmdlet behaviour can both decrease script size and complexity.</p>
<p>Have fun experimenting with this little trick</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cupfighter.net/index.php/2009/06/powershell-controlling-cmdlet-parameters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

