<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>PowerShell Ponderings &#187; PowerShell &#8211; Functions</title>
	<atom:link href="http://andrwwatt.wordpress.com/category/powershell-functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://andrwwatt.wordpress.com</link>
	<description>Pondering the power of PowerShell</description>
	<lastBuildDate>Fri, 19 May 2006 09:06:24 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='andrwwatt.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/7a3577429727eb864e230a6da306b64a?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>PowerShell Ponderings &#187; PowerShell &#8211; Functions</title>
		<link>http://andrwwatt.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://andrwwatt.wordpress.com/osd.xml" title="PowerShell Ponderings" />
		<item>
		<title>Coping with a PowerShell naming clash</title>
		<link>http://andrwwatt.wordpress.com/2006/05/13/coping-with-a-powershell-naming-clash/</link>
		<comments>http://andrwwatt.wordpress.com/2006/05/13/coping-with-a-powershell-naming-clash/#comments</comments>
		<pubDate>Sat, 13 May 2006 16:32:56 +0000</pubDate>
		<dc:creator>andrwwatt</dc:creator>
				<category><![CDATA[PowerShell - Aliases]]></category>
		<category><![CDATA[PowerShell - Functions]]></category>
		<category><![CDATA[Powershell - Cmdlets]]></category>

		<guid isPermaLink="false">https://andrwwatt.wordpress.com/2006/05/13/coping-with-a-powershell-naming-clash/</guid>
		<description><![CDATA[Naming clashes are something I expect to increase in frequency when PowerShell starts to be used more widely. I thought I would show you how to solve some categories of naming clashes. I will deal here with some of the situations that can arise when naming functions using names similar to cmdlets, that is verb-noun.
The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrwwatt.wordpress.com&blog=221566&post=8&subd=andrwwatt&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Naming clashes are something I expect to increase in frequency when PowerShell starts to be used more widely. I thought I would show you how to solve some categories of naming clashes. I will deal here with some of the situations that can arise when naming functions using names similar to cmdlets, that is <i>verb-noun</i>.</p>
<p>The situation can, potentially, become really complex so I will deal in this post only with some simple situations.</p>
<p>The name of a function can clash with an existing alias or cmdlet name. As an example consider what happens if you have written a function called <b>rename-item</b>.  If you&#39;ve been reading recent posts on this blog you will know that PowerShell has a <b>rename-item</b> cmdlet.</p>
<p>Assume that you have opened a fresh PowerShell console window.</p>
<p>If you type <b>rename-item</b> at the command line then you see a prompt</p>
<p><b>PS C:\&gt; rename-item</b></p>
<p><b>cmdlet rename-item at command pipeline position 1<br />
Supply values for the following parameters:<br />
Path: </b></p>
<p>PowerShell prompts you to supply a value for the <b>Path</b> parameter.</p>
<p>Press Ctrl+C to stop this.</p>
<p>At the command line type the following to create the <b>rename-item</b> function:</p>
<p><b>function rename-item{</b></p>
<p><b>write-host &quot;This output is from the rename-item function&quot;</b></p>
<p><b>} </b></p>
<p>Then type at the command line:</p>
<p><b>rename-item</b></p>
<p>You will see an appearance like this:</p>
<p><b>PS C:\&gt; rename-item<br />
This output is from the rename-item function<br />
PS C:\&gt; </b></p>
<p>By creating a function called <b>rename-item</b> you have, effectively, blocked execution of the <b>rename-item</b> cmdlet at the command line.</p>
<p>Why does this happen? PowerShell attempts to find an executable to match a command in the following order:</p>
<ol>
<li>Aliases</li>
<li>Functions</li>
<li>Cmdlets</li>
<li>Executables</li>
<li>Scripts</li>
<li>Normal files</li>
</ol>
<p>So when you created the <b>rename-item</b> function it takes precedence over the <b>rename-item</b> cmdlet.</p>
<p>If you want to be sure to have access to the <b>rename-item</b> cmdlet avoid creating a global function with that name since the function will always have higher priority than the cmdlet.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/andrwwatt.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/andrwwatt.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andrwwatt.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andrwwatt.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andrwwatt.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andrwwatt.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andrwwatt.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andrwwatt.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andrwwatt.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andrwwatt.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andrwwatt.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andrwwatt.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrwwatt.wordpress.com&blog=221566&post=8&subd=andrwwatt&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://andrwwatt.wordpress.com/2006/05/13/coping-with-a-powershell-naming-clash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bbd01d97e4b6b8a5c05a55b10c599ce2?s=96&#38;d=identicon" medium="image">
			<media:title type="html">andrwwatt</media:title>
		</media:content>
	</item>
	</channel>
</rss>